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 a[4]={1},ans,s;
void f(){
for(int i=3;i;--i)if(a[i-1]){
if(i>2)ans+=a[i];
a[i]=1;
}
}
void g(){
for(int i=4;i--;){
if(i>2)ans+=a[i];
else a[i+1]=a[i];
if(i)a[i]=0;
}
}
int main(){
int n,k;
scanf("%d",&n);
for(;n--;){
scanf("%d",&k);
if(k==1)if(++s>3)f(),s=0;
else if(k==2)s=0,f();
else{
if(++s>3)f(),s=0;
else g();
}
}
printf("%d",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... |