This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |