[SWEA] 8888 시험

Time Lapse :3hour 12min 56sec

8888.c

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
#include <stdio.h>
#include <memory.h>

using namespace std;
int Tests[2001];
bool isSolved[2001][2001];
int Solved[2001];
int scores[2001];
void solution(int tc){
int N,T,P;
char score;
scanf("%d%d%d",&N,&T,&P);
getchar();
memset(Tests,0,sizeof(Tests));
memset(isSolved,false,sizeof(isSolved));
memset(Solved,0,sizeof(Solved));
for(int i=1;i<=N;i++){
for(int j=0;j<T;j++){
score = getchar();
getchar();
if(score=='0'){
++Tests[j];
}else{
isSolved[i][j]=true;
++Solved[i];
}
}
}

memset(scores,0,sizeof(scores));
for(int i=0;i<T;i++){
if(isSolved[P][i])
scores[P] += Tests[i];
}
int standard_score = scores[P];
int standard_solved = Solved[P];
int rank = 1;
for(int i=1;i<=N;i++){
if(i==P)
continue;
for(int j=0;j<T;j++) {
if (isSolved[i][j]) {
scores[i] += Tests[j];
}
}
if(scores[i]>standard_score)
++rank;
else if(scores[i]==standard_score){
if(Solved[i]>standard_solved)
++rank;
else if(Solved[i]==standard_solved)
if(i<P)
++rank;
}
}
printf("#%d %d %d\n",tc,standard_score,rank);
return ;
}
int main(int argc, char** argv)
{
int test_case;
int T;
scanf("%d",&T);
for(test_case = 1; test_case <= T; ++test_case){
solution(test_case);
}
return 0;//정상종료시 반드시 0을 리턴해야합니다.
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/8888/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.