#include<cstdio>
int main()
{
int i,n,r=0;
int w,x,y,z;
scanf("%d",&n);
w=x=y=z=0;
while(n--)
{
scanf("%d",&i);
if(i==1)
{
w++;
if(w==4)
{
w=0;
x++;
if(x>1)
{
y++;
x--;
}
if(y>1)
{
z++;
y--;
}
if(z>1)
{
r++;
z--;
}
}
}
if(i==2)
{
w=0;
x++;
if(x>1)
{
y++;
x--;
}
if(y>1)
{
z++;
y--;
}
if(z>1)
{
r++;
z--;
}
}
if(i==3)
{
w++;
r+=z;
z=y;
y=x;
x=0;
if(w==4)
{
w=0;
x++;
if(x>1)
{
y++;
x--;
}
if(y>1)
{
z++;
y--;
}
if(z>1)
{
r++;
z--;
}
}
}
}
printf("%d",r);
}
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 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 |
6 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 |
6 ms |
1084 KB |
Output is correct |
2 |
Correct |
7 ms |
1084 KB |
Output is correct |
3 |
Correct |
6 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 |
6 ms |
1084 KB |
Output is correct |
7 |
Correct |
0 ms |
1084 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
1084 KB |
Output is correct |
12 |
Correct |
6 ms |
1084 KB |
Output is correct |
13 |
Correct |
4 ms |
1084 KB |
Output is correct |
14 |
Correct |
6 ms |
1084 KB |
Output is correct |
15 |
Correct |
3 ms |
1084 KB |
Output is correct |