求助leetcode的892能过,360第一题只过了9%

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int row = scanner.nextInt();
        int col = scanner.nextInt();
        if (row < 1||row>100000 || col < 1 || col>100000) {
            System.out.println(0);
            return;
        }
        int[][] map = new int[row][col];
        int all = 0;
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < col; j++) {
                int value = scanner.nextInt();
                map[i][j] = value;
                all += value*6;
                if(value>1)
                    all= all-(value-1)*2;
                if(i>0 && map[i-1][j]>0)
                    all = all-Math.min(value,map[i-1][j])*2;
                if(j>0 && map[i][j-1]>0)
                    all = all-Math.min(value,map[i][j-1])*2;
            }
        }
        System.out.println(all);
    }
}
只能过9%,好想知道为什么
#360公司##leetcode##笔试题目#
全部评论
题目都没注意吗?
点赞 回复 分享
发布于 2019-08-15 21:47
真的是原题吗,我看看。兄弟,题目条件不一样。不认真看题了吗?leetcode是n*n的;今天考的是n*m;
点赞 回复 分享
发布于 2019-08-15 21:47
直接输出测试用例结果百分之18...
点赞 回复 分享
发布于 2019-08-15 21:23
也不是那个int和long问题
点赞 回复 分享
发布于 2019-08-15 21:22

相关推荐

10-09 09:19
已编辑
沈阳农业大学 C++
修订
丿南烟丶:个人评价可以删掉 两个项目都是轮子项目,把一个转换成应用型项目,把MySQL和redis用起来 另外项目的时间可以标明一下
最后再改一次简历
点赞 评论 收藏
分享
评论
点赞
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务