[BOJ] 1268 임시 반장 정하기

Time Lapse :None

1268.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
int s[1000][5];
int info[1000];
int close[1000][1000];
int N, val, ans;
int main() {
scanf("%d", &N);
for(int i = 0; i < N; ++i)
scanf("%d %d %d %d %d", &s[i][0], &s[i][1], &s[i][2], &s[i][3], &s[i][4]);
for (int i = 0; i < 5; ++i)
for (int j = 0; j < N - 1; ++j)
for (int k = j + 1; k < N; ++k) {
if (close[j][k]) continue;
if (s[j][i] == s[k][i]) {
++info[j], ++info[k];
close[j][k] = close[k][j] = 1;
}
}
for (int i = 0; i < N; ++i)
if (info[i] > val) val = info[i], ans = i;
printf("%d", ans + 1);

}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/23/PS/BOJ/1268/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.