CCF201909-1小明种苹果java

CCF201909-1小明种苹果 java

    • 题目
    • 代码

题目

图片:
CCF201909-1小明种苹果java_第1张图片

代码

public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int trees = scanner.nextInt();
        int times = scanner.nextInt();
        scanner.nextLine();
        int T = 0;
        int k = 0;
        int P = 0;
        int kkk = 0;
        for (int i = 0; i < trees; i++) {
            String arg = scanner.nextLine();
            String[] cc = arg.trim().split(" ");
            int eachCount = Integer.parseInt(cc[0]);
            int kk = 0;
            for (int j = 0; j < times; j++) {
                kk += Integer.parseInt(cc[j + 1]);
            }
            T += eachCount + kk;
            if (-kk > kkk) {
                kkk = -kk;
                k = i + 1;
                P = -kk;
            }
        }
        String result = T + " " + k + " " + P;
        System.out.print(result);
    }

你可能感兴趣的:(CCF201909-1小明种苹果java)