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 t,n,i,j,s,c,ans,a[4];
void f1()
{
if(a[3]&&a[2]&&a[1])a[3]--,ans++;
if(a[2]&&a[1])a[2]--,a[3]++;
if(a[1])a[2]++,a[1]--;a[1]++;
}
void f2()
{
if(a[3])ans++;
if(a[2])a[2]--,a[3]++;
if(a[1])a[1]--,a[2]++;
}
int main()
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&t);
if(t==1)
{
if(c==3)
{
f1();
c=0;
}
else c++;
}
else if(t==2)
{
f1();
c=0;
}
else if(t==3)
{
f2();
if(c==3)
{
a[1]++;
c=0;
}
else c++;
}
}
printf("%d",ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |