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 <cstdio>
int n;
int ans;
int buf;
int ballcnt;
bool j1,j2,j3;
int main()
{
scanf("%d",&n);
for(;n--;){
scanf("%d",&buf);
if(buf==1){
//puts("ball");
++ballcnt;
if(ballcnt==4){
//puts("");
if(j1){
if(j2){
if(j3){
++ans; j3=false;
}
j3=true; j2=false;
}
j2=true; j1=false;
}
j1=true;
ballcnt=0;
}
} else if(buf==2){
//puts("beanball\n");
if(j1){
if(j2){
if(j3){
++ans; j3=false;
}
j3=true; j2=false;
}
j2=true; j1=false;
}
ballcnt=0;
j1=true;
} else {
//puts("asdf");
++ballcnt;
ans+=j3; j3=false;
j3=j2; j2=false;
j2=j1; j1=false;
if(ballcnt==4) j1=true, ballcnt=0;
}
//printf("Current state %d %d %d\n",j1,j2,j3);
}
printf("%d\n",ans);
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... |