#include <stdio.h>
int ball[4],base[4];
int main()
{
int n,a,i,s=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&a);
ball[a]++;
if(ball[1]==4||a==2){
if(base[3]&&base[2]&&base[1])s++;
else if(base[2]&&base[1]) base[3]=1;
else if(base[3]&&base[1]||base[1]) base[2]=1;
base[1]=1;
ball[1]=0;
}
if(a==3){
ball[1]++;
if(base[3])s++,base[3]=0;
if(base[2])base[3]=1,base[2]=0;
if(base[1])base[2]=1,base[1]=0;
if(ball[1]==4)base[1]=1;
}
//printf("%d %d %d\n%d %d %d\n%d\n",ball[1],ball[2],ball[3],base[1],base[2],base[3],s);
}
printf("%d",s);
return 0;
}
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
1084 KB |
Output is correct |
5 |
Correct |
6 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
0 ms |
1084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
1084 KB |
Output isn't correct |
4 |
Correct |
0 ms |
1084 KB |
Output is correct |
5 |
Correct |
0 ms |
1084 KB |
Output is correct |
6 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
7 |
Incorrect |
6 ms |
1084 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
1084 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1084 KB |
Output isn't correct |
3 |
Correct |
0 ms |
1084 KB |
Output is correct |
4 |
Incorrect |
6 ms |
1084 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
1084 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
7 |
Incorrect |
7 ms |
1084 KB |
Output isn't correct |
8 |
Incorrect |
6 ms |
1084 KB |
Output isn't correct |
9 |
Incorrect |
5 ms |
1084 KB |
Output isn't correct |
10 |
Incorrect |
4 ms |
1084 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
1084 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
14 |
Incorrect |
7 ms |
1084 KB |
Output isn't correct |
15 |
Incorrect |
7 ms |
1084 KB |
Output isn't correct |