Written on
·
291
0
import java.util.*;
public class Main {
public int solution(int n, int[][] arr) {
int answer = 0;
int[] stu = new int[n];
int cnt;
int sum = 0;
for (int i = 0; i < n; i++) {
cnt = 0;
for (int j = 0; j < 5; j++) {
for (int k = 0; k < n; k++) {
if (i != j && arr[i][k] == arr[j][k]) {
cnt++;
stu[i] += cnt;
cnt = 0;
}
}
}
sum = Math.max(sum, stu[i]);
if (sum == stu[i]) {
answer = i + 1;
}
}
return answer;
}
public static void main(String[] args) {
Main T = new Main();
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] arr = new int[n][5];
for (int i = 0; i < n; i++) {
for (int j = 0; j < 5; j++) {
arr[i][j] = sc.nextInt();
}
}
System.out.print(T.solution(n, arr));
}
}
Answer 1
0