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