#include<stdio.h>
int n,x;
int b1,b2,b3,cnt,dap;
int main()
{
int i;
//freopen("input.txt","r",stdin);
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&x);
if(x==1) cnt++;
if(x==2) cnt=4;
if(x==3)
{
if(b3) dap++, b3=0;
if(b2) b3=1, b2=0;
if(b1) b2=1, b1=0;
cnt++;
}
if(cnt==4)
{
if(b1==0) b1=1;
else if(b1==1 && b2==0) b2=1;
else if(b1==1 && b2==1 && b3==0) b3=1;
else if(b1==1 && b2==1 && b3==1) dap++;
cnt=0;
}
}
printf("%d",dap);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1084 KB |
Output is correct |
2 |
Correct |
3 ms |
1084 KB |
Output is correct |
3 |
Correct |
0 ms |
1084 KB |
Output is correct |
4 |
Correct |
0 ms |
1084 KB |
Output is correct |
5 |
Correct |
0 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
0 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Correct |
5 ms |
1084 KB |
Output is correct |
3 |
Correct |
3 ms |
1084 KB |
Output is correct |
4 |
Correct |
7 ms |
1084 KB |
Output is correct |
5 |
Correct |
0 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
0 ms |
1084 KB |
Output is correct |
8 |
Correct |
0 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Correct |
0 ms |
1084 KB |
Output is correct |
4 |
Correct |
0 ms |
1084 KB |
Output is correct |
5 |
Correct |
4 ms |
1084 KB |
Output is correct |
6 |
Correct |
0 ms |
1084 KB |
Output is correct |
7 |
Correct |
0 ms |
1084 KB |
Output is correct |
8 |
Correct |
6 ms |
1084 KB |
Output is correct |
9 |
Correct |
0 ms |
1084 KB |
Output is correct |
10 |
Correct |
0 ms |
1084 KB |
Output is correct |
11 |
Correct |
7 ms |
1084 KB |
Output is correct |
12 |
Correct |
0 ms |
1084 KB |
Output is correct |
13 |
Correct |
3 ms |
1084 KB |
Output is correct |
14 |
Correct |
4 ms |
1084 KB |
Output is correct |
15 |
Correct |
6 ms |
1084 KB |
Output is correct |