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 main()
{
int n,base[3]={0},ballnum=0,score=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
int ball,newbase[3]={0};
scanf("%d",&ball);
if(ball==1){
ballnum++;
if(ballnum!=4){
for(int j=0;j<4;j++)newbase[j]=base[j];
}
if(ballnum==4&&base[0])newbase[1]=1;
if(ballnum==4&&base[0]&&base[1])newbase[2]=1;
else if(ballnum==4&&base[1])newbase[1]=1;
if(ballnum==4&&base[0]&&base[1]&&base[2])score++;
else if(ballnum==4&&base[2])newbase[2]=1;
if(ballnum==4){
newbase[0]=1;
ballnum=0;
}
}
if(ball==2){
if(base[0])newbase[1]=1;
if(base[0]&&base[1])newbase[2]=1;
else if(base[1])newbase[1]=1;
if(base[0]&&base[1]&&base[2])score++;
else if(base[2])newbase[2]=1;
newbase[0]=1;
ballnum=0;
}
if(ball==3){
ballnum++;
if(ballnum==4){
newbase[0]=1;
ballnum=0;
}
if(base[0])newbase[1]=1;
if(base[1])newbase[2]=1;
if(base[2])score++;
}
for(int j=0;j<3;j++)base[j]=newbase[j];
}
printf("%d",score);
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... |