#include<stdio.h>
int R[5];
int main(){
int N, i, j, Ball=0, a;
scanf("%d", &N);
for(i=1; i<=N; i++){
scanf("%d", &a);
if(a==1) Ball++;
if(a==3){
Ball++;
for(j=3; j>=1; j--){
if(R[j]) R[j+1]++;
R[j]=0;
}
}
if(a==2 || Ball==4){
Ball=0;
if(R[1]==1 && R[2]==1 && R[3]==1) R[4]++;
else if(R[1]==1 && R[2]==1) R[3]=1;
else if(R[1]==1) R[2]=1;
else R[1]=1;
}
}
printf("%d", R[4]);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Correct |
0 ms |
1084 KB |
Output is correct |
4 |
Correct |
1 ms |
1084 KB |
Output is correct |
5 |
Correct |
2 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
2 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Correct |
6 ms |
1084 KB |
Output is correct |
4 |
Correct |
3 ms |
1084 KB |
Output is correct |
5 |
Correct |
1 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
6 ms |
1084 KB |
Output is correct |
8 |
Correct |
0 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1084 KB |
Output is correct |
2 |
Correct |
7 ms |
1084 KB |
Output is correct |
3 |
Correct |
7 ms |
1084 KB |
Output is correct |
4 |
Correct |
6 ms |
1084 KB |
Output is correct |
5 |
Correct |
0 ms |
1084 KB |
Output is correct |
6 |
Correct |
7 ms |
1084 KB |
Output is correct |
7 |
Correct |
0 ms |
1084 KB |
Output is correct |
8 |
Correct |
6 ms |
1084 KB |
Output is correct |
9 |
Correct |
6 ms |
1084 KB |
Output is correct |
10 |
Correct |
0 ms |
1084 KB |
Output is correct |
11 |
Correct |
6 ms |
1084 KB |
Output is correct |
12 |
Correct |
7 ms |
1084 KB |
Output is correct |
13 |
Correct |
0 ms |
1084 KB |
Output is correct |
14 |
Correct |
0 ms |
1084 KB |
Output is correct |
15 |
Correct |
0 ms |
1084 KB |
Output is correct |