输入输出样例

样例1

输入

  1. 3 3
  2. 73 -8 -6 -4
  3. 76 -5 -10 -8
  4. 80 -6 -15 0

输出

  1. 167 2 23

样例2

输入

  1. 2 2
  2. 10 -3 -1
  3. 15 -4 0

输出

  1. 17 1 4

题解一

模拟。100分。

  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. public class Main {
  5. public static void main(String[] args) throws IOException {
  6. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  7. String[] strs = reader.readLine().trim().split(" ");
  8. int n = Integer.parseInt(strs[0]);
  9. int m = Integer.parseInt(strs[1]);
  10. int sum = 0;
  11. int ansIndex = 0;
  12. int maxRemoveNum = 0;
  13. int total, removeNum;
  14. for (int i = 0; i < n; ++i) {
  15. strs = reader.readLine().trim().split(" ");
  16. total = Integer.parseInt(strs[0]);
  17. removeNum = 0;
  18. for (int j = 1; j <= m; ++j) {
  19. removeNum += -Integer.parseInt(strs[j]);
  20. }
  21. total -= removeNum;
  22. sum += total;
  23. if (removeNum > maxRemoveNum) {
  24. maxRemoveNum = removeNum;
  25. ansIndex = i + 1;
  26. }
  27. }
  28. System.out.println(sum+" "+ansIndex+" "+maxRemoveNum);
  29. }
  30. }