#include <stdio.h>
int bace[5],a[50001],bc=0,i,j,n,score=0;
int main(void)
{
FILE *in;
in=stdin;//fopen("input.txt","r");
fscanf(in,"%d",&n);
for(i=0;i<n;i++){
fscanf(in,"%d",&a[i]);
if(a[i]==3){
if(bace[3]==1){
score++;
bace[3]=0;
}
bace[3]=bace[2];
bace[2]=bace[1];
bace[1]=0;
}
if(a[i]==1 || a[i]==3)
bc++;
if(bc==4 ||a[i]==2){
bc=0;
if(bace[1]==1 && bace[2]==1 && bace[3]==1)
score++;
else if(bace[1]==1 && bace[2]==1)
bace[3]=1;
else if(bace[1]==1)
bace[2]=1;
else bace[1]=1;
}
// printf("%d %d %d %d\n",bace[1],bace[2],bace[3],bc);
}
printf("%d",score);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
0 ms |
1276 KB |
Output is correct |
4 |
Correct |
0 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
1 ms |
1276 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
2 ms |
1276 KB |
Output is correct |
4 |
Correct |
5 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
0 ms |
1276 KB |
Output is correct |
7 |
Correct |
0 ms |
1276 KB |
Output is correct |
8 |
Correct |
6 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1276 KB |
Output is correct |
2 |
Correct |
5 ms |
1276 KB |
Output is correct |
3 |
Correct |
0 ms |
1276 KB |
Output is correct |
4 |
Correct |
6 ms |
1276 KB |
Output is correct |
5 |
Correct |
6 ms |
1276 KB |
Output is correct |
6 |
Correct |
3 ms |
1276 KB |
Output is correct |
7 |
Correct |
3 ms |
1276 KB |
Output is correct |
8 |
Correct |
6 ms |
1276 KB |
Output is correct |
9 |
Correct |
7 ms |
1276 KB |
Output is correct |
10 |
Correct |
0 ms |
1276 KB |
Output is correct |
11 |
Correct |
0 ms |
1276 KB |
Output is correct |
12 |
Correct |
5 ms |
1276 KB |
Output is correct |
13 |
Correct |
0 ms |
1276 KB |
Output is correct |
14 |
Correct |
0 ms |
1276 KB |
Output is correct |
15 |
Correct |
7 ms |
1276 KB |
Output is correct |