#include <cstdio>
int n;
int ans;
int buf;
int ballcnt;
bool j1,j2,j3;
int main()
{
scanf("%d",&n);
for(;n--;){
scanf("%d",&buf);
if(buf==1){
//puts("ball");
++ballcnt;
if(ballcnt==4){
//puts("");
if(j1){
if(j2){
if(j3){
++ans; j3=false;
}
j3=true; j2=false;
}
j2=true; j1=false;
}
j1=true;
ballcnt=0;
}
} else if(buf==2){
//puts("beanball\n");
if(j1){
if(j2){
if(j3){
++ans; j3=false;
}
j3=true; j2=false;
}
j2=true; j1=false;
}
ballcnt=0;
j1=true;
} else {
//puts("asdf");
++ballcnt;
ans+=j3; j3=false;
j3=j2; j2=false;
j2=j1; j1=false;
if(ballcnt==4) j1=true, ballcnt=0;
}
//printf("Current state %d %d %d\n",j1,j2,j3);
}
printf("%d\n",ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
2 ms |
1084 KB |
Output is correct |
5 |
Correct |
3 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 |
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 |
3 ms |
1084 KB |
Output is correct |
8 |
Correct |
3 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 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 |
0 ms |
1084 KB |
Output is correct |
6 |
Correct |
1 ms |
1084 KB |
Output is correct |
7 |
Correct |
3 ms |
1084 KB |
Output is correct |
8 |
Correct |
7 ms |
1084 KB |
Output is correct |
9 |
Correct |
6 ms |
1084 KB |
Output is correct |
10 |
Correct |
0 ms |
1084 KB |
Output is correct |
11 |
Correct |
0 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 |
0 ms |
1084 KB |
Output is correct |
15 |
Correct |
5 ms |
1084 KB |
Output is correct |