#include <stdio.h>
int ball[50001];
int base[5];
int main()
{
int n;
scanf("%d", &n);
int i, j;
for (i = 1; i <= n; i++)
scanf("%d", &ball[i]);
int score = 0;
int count = 0;
for (i = 1; i <= n; i++)
{
if (ball[i] == 1)
count += 1;
else if (ball[i] == 2)
{
for (j = 1; j <= 4; j++)
{
if (base[4] == 1)
break;
if (base[j] == 1)
{
base[j] = 2;
if (base[j - 1] == 2)
base[j - 1] = 1;
}
else
{
if (base[j - 1] == 2)
{
base[j] = 1;
base[j - 1] = 1;
}
break;
}
}
count = 0;
base[1] = 1;
}
else if (ball[i] == 3)
{
for (j = 3; j >= 1; j--)
{
if (base[j] == 1)
{
base[j + 1] = 1;
base[j] = 0;
}
}
count += 1;
}
if (count == 4)
{
for (j = 1; j <= 4; j++)
{
if (base[4] == 1)
break;
if (base[j] == 1)
{
base[j] = 2;
if (base[j - 1] == 2)
base[j - 1] = 1;
}
else
{
if (base[j - 1] == 2)
{
base[j] = 1;
base[j - 1] = 1;
}
break;
}
}
count = 0;
base[1] = 1;
}
if (base[4] == 1)
{
score += 1;
base[4] = 0;
}
}
printf("%d", score);
return 0;
}
# |
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 |
0 ms |
1276 KB |
Output is correct |
4 |
Correct |
0 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 |
7 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 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 |
Correct |
0 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 |
8 |
Correct |
7 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1276 KB |
Output is correct |
2 |
Correct |
0 ms |
1276 KB |
Output is correct |
3 |
Correct |
7 ms |
1276 KB |
Output is correct |
4 |
Correct |
0 ms |
1276 KB |
Output is correct |
5 |
Correct |
7 ms |
1276 KB |
Output is correct |
6 |
Correct |
5 ms |
1276 KB |
Output is correct |
7 |
Correct |
0 ms |
1276 KB |
Output is correct |
8 |
Correct |
1 ms |
1276 KB |
Output is correct |
9 |
Correct |
5 ms |
1276 KB |
Output is correct |
10 |
Correct |
5 ms |
1276 KB |
Output is correct |
11 |
Correct |
0 ms |
1276 KB |
Output is correct |
12 |
Correct |
7 ms |
1276 KB |
Output is correct |
13 |
Correct |
0 ms |
1276 KB |
Output is correct |
14 |
Correct |
6 ms |
1276 KB |
Output is correct |
15 |
Correct |
6 ms |
1276 KB |
Output is correct |