#include <stdio.h>
int n;
int a[50010];
int b[5];
int ball;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++){
if(a[i]==1)
{
ball++;
if(ball==4)
{
ball=0;
b[0]++;
for(int j=3;j>=0;j--){
if(j==0||b[j]==1&&b[j-1]==1)
{
b[j+1]++;
b[j]--;
}
}
}
}
if(a[i]==2)
{
ball=0;
b[0]++;
for(int j=3;j>=0;j--){
if(j==0||b[j]>=1&&b[j-1]==1)
{
b[j+1]++;
b[j]--;
}
}
}
if(a[i]==3)
{
ball++;
if(ball==4)
{
ball=0;
b[0]++;
for(int j=3;j>=0;j--){
if(j==0||b[j]==1&&b[j-1]==1)
{
b[j+1]++;
b[j]--;
}
}
}
else{
for(int j=3;j>=0;j--){
if(b[j]>=1)
{
b[j+1]++;
b[j]--;
}
}
}
}
}
printf("%d",b[4]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1276 KB |
Output is correct |
4 |
Correct |
7 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Correct |
0 ms |
1276 KB |
Output is correct |
7 |
Correct |
0 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1276 KB |
Output isn't correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1276 KB |
Output is correct |
4 |
Correct |
4 ms |
1276 KB |
Output is correct |
5 |
Correct |
0 ms |
1276 KB |
Output is correct |
6 |
Incorrect |
0 ms |
1276 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
1276 KB |
Output isn't correct |
8 |
Correct |
0 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
0 ms |
1276 KB |
Output is correct |
4 |
Incorrect |
5 ms |
1276 KB |
Output isn't correct |
5 |
Correct |
6 ms |
1276 KB |
Output is correct |
6 |
Correct |
3 ms |
1276 KB |
Output is correct |
7 |
Correct |
6 ms |
1276 KB |
Output is correct |
8 |
Incorrect |
2 ms |
1276 KB |
Output isn't correct |
9 |
Correct |
3 ms |
1276 KB |
Output is correct |
10 |
Correct |
0 ms |
1276 KB |
Output is correct |
11 |
Correct |
0 ms |
1276 KB |
Output is correct |
12 |
Incorrect |
7 ms |
1276 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
1276 KB |
Output isn't correct |
14 |
Incorrect |
6 ms |
1276 KB |
Output isn't correct |
15 |
Correct |
0 ms |
1276 KB |
Output is correct |