Untitled
unknown
plain_text
19 days ago
884 B
41
Indexable
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); // number of students int m = in.nextInt(); // number of lessons int[] studentOrder = new int[n]; for (int i = 0; i < n; i++) { studentOrder[i] = in.nextInt(); } int bestStudentIndex = -1; int maxSum = -1; for (int i = 0; i < n; i++) { //this is how you find the student with the maximum total grade int sum = 0; for (int j = 0; j < m; j++) { sum += in.nextInt(); } if (sum > maxSum) { maxSum = sum; bestStudentIndex = i; } } System.out.println(studentOrder[bestStudentIndex]); } }
Editor is loading...
Leave a Comment