-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6913.cpp
More file actions
68 lines (62 loc) · 1.18 KB
/
6913.cpp
File metadata and controls
68 lines (62 loc) · 1.18 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 6913. 동철이의 프로그래밍 대회
// 2019.06.29
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
int state[21][21];
int result[21]; // result[i] : i번째 사람이 맞춘 문제 수
int main()
{
int t;
cin >> t;
for (int testCase = 1; testCase <= t; testCase++)
{
int n, m;
cin >> n >> m;
fill(result, result + 21, 0);
for (int i = 0; i < 21; i++)
{
fill(state[i], state[i] + 21, 0);
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> state[i][j];
}
}
// 맞춘 문제 수 계산
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
result[i] += state[i][j];
}
}
// 맞춘 문제수의 최댓값 계산
int maxVal = 0;
for (int i = 0; i < 21; i++)
{
maxVal = max(result[i], maxVal);
}
// 1등한 사람의 수 계산
int people = 0;
for (int i = 0; i < 21; i++)
{
if (result[i] == maxVal)
{
people++;
}
}
// 예외처리 : 아무도 어떠한 문제도 맞추지 못한 상태
if (maxVal == 0)
{
people = n;
}
cout << "#" << testCase << " " << people << " " << maxVal << endl;
}
return 0;
}