输入输出样例
样例1
输入
3 3
73 -8 -6 -4
76 -5 -10 -8
80 -6 -15 0
输出
167 2 23
样例2
输入
2 2
10 -3 -1
15 -4 0
输出
17 1 4
题解一
模拟。100分。
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] strs = reader.readLine().trim().split(" ");
int n = Integer.parseInt(strs[0]);
int m = Integer.parseInt(strs[1]);
int sum = 0;
int ansIndex = 0;
int maxRemoveNum = 0;
int total, removeNum;
for (int i = 0; i < n; ++i) {
strs = reader.readLine().trim().split(" ");
total = Integer.parseInt(strs[0]);
removeNum = 0;
for (int j = 1; j <= m; ++j) {
removeNum += -Integer.parseInt(strs[j]);
}
total -= removeNum;
sum += total;
if (removeNum > maxRemoveNum) {
maxRemoveNum = removeNum;
ansIndex = i + 1;
}
}
System.out.println(sum+" "+ansIndex+" "+maxRemoveNum);
}
}