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