编程语言
首页 > 编程语言> > CCF 201909-1 小明种苹果(100分)Java

CCF 201909-1 小明种苹果(100分)Java

作者:互联网

 

 注意输入和输出的格式,这是认证时候提交代码

import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }
    
    public void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] count = new int[n][m+1];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m+1; j++) {
                count[i][j] = sc.nextInt();
            }
        }
        
        int[] sum = new int[n];
        int[] del = new int[n];
        int allSum = 0;
        for(int i = 0; i < n; i++) {
            sum[i] = count[i][0];
            for(int j = 1; j < m+1; j++) {
                sum[i] += count[i][j];
            }
            del[i] = count[i][0] - sum[i];
            allSum += sum[i];
        }
        int index = 1;
        int max = del[0];
        for(int i = 1; i < n; i++) {
            if(del[i] > max) {
                max = del[i];
                index = i + 1;
            }
        }
        System.out.println(allSum+" "+index+" "+max);
        
    }
}

标签:count,Java,小明种,int,sum,++,del,new,100
来源: https://www.cnblogs.com/bruce1920/p/12051287.html