-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecidePerson.java
More file actions
38 lines (34 loc) · 990 Bytes
/
DecidePerson.java
File metadata and controls
38 lines (34 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.Scanner;
public class DecidePerson {
public int solution(int n, int[][] arr){
int answer = 0, max = Integer.MIN_VALUE;
for (int i=0; i<n; i++){
int tmp=0;
for (int j=0; j<n; j++){
for (int k =0; k<5; k++){
if(arr[i][k] == arr[j][k]){
tmp++;
break;
}
}
}
if(max < tmp){
answer = i;
max=tmp;
}
}
return answer+1;
}
public static void main(String[] args) {
DecidePerson t = new DecidePerson();
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[][] arr = new int[n][5];
for (int i=0;i<n;i++){
for(int j=0;j<5;j++){
arr[i][j] = scanner.nextInt();
}
}
System.out.println(t.solution(n, arr));
}
}