代码如下:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[][] nm = new int[n][m+1];
//总数
int t = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m+1; j++) {
nm[i][j] = scanner.nextInt();
}
}
//输出的下标值
int k = 0;
//输出的下标为k的蔬果个数
int p = 0;
for (int i = 0; i < n; i++) {
t += nm[i][0];
int mid = 0;
for (int j = 1; j < m+1; j++) {
mid += nm[i][j];
}
if (mid<p){
k = i+1;
p = mid;
}
t = t + mid;
}
System.out.println(t+"\t"+k+"\t"+(-p));
}
}