#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
#include<iomanip>
#include<functional>
#include<stack>
#include<set>
#include<map>
#include<queue>
using namespace std;
int n;
int ballCnt;
bool isBase[3];
int res = 0;
int sol(int pos)
{
if (pos >= 3)
return 1;
if (!isBase[pos])
{
isBase[pos] = true;
return 0;
}
int ret = 0;
if (isBase[pos])
res += sol(pos + 1);
return ret;
}
int main()
{
#ifdef _CONSOLE
freopen("input.txt", "r", stdin);
#endif
//////////////////////////////////////////////////
scanf("%d", &n);
while (n--)
{
int point;
scanf("%d", &point);
if (point == 1)
{
ballCnt++;
if (ballCnt == 4)
{
res += sol(0);
ballCnt = 0;
}
}
else if (point == 2)
{
res += sol(0);
ballCnt = 0;
}
else
{
ballCnt++;
if (isBase[2])
{
res++;
isBase[2] = false;
}
for (int i = 1; i >= 0; i--)
{
if (isBase[i])
{
isBase[i + 1] = true;
isBase[i] = false;
}
}
if (ballCnt == 4)
{
isBase[0] = true;
ballCnt = 0;
}
}
}
printf("%d\n", res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1720 KB |
Output is correct |
2 |
Correct |
2 ms |
1720 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
0 ms |
1720 KB |
Output is correct |
5 |
Correct |
6 ms |
1720 KB |
Output is correct |
6 |
Correct |
0 ms |
1720 KB |
Output is correct |
7 |
Correct |
0 ms |
1720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1720 KB |
Output is correct |
2 |
Correct |
0 ms |
1720 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
0 ms |
1720 KB |
Output is correct |
5 |
Correct |
0 ms |
1720 KB |
Output is correct |
6 |
Correct |
6 ms |
1720 KB |
Output is correct |
7 |
Correct |
0 ms |
1720 KB |
Output is correct |
8 |
Correct |
3 ms |
1720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
1720 KB |
Output is correct |
2 |
Correct |
0 ms |
1720 KB |
Output is correct |
3 |
Correct |
0 ms |
1720 KB |
Output is correct |
4 |
Correct |
0 ms |
1720 KB |
Output is correct |
5 |
Correct |
0 ms |
1720 KB |
Output is correct |
6 |
Correct |
4 ms |
1720 KB |
Output is correct |
7 |
Correct |
4 ms |
1720 KB |
Output is correct |
8 |
Correct |
0 ms |
1720 KB |
Output is correct |
9 |
Correct |
0 ms |
1720 KB |
Output is correct |
10 |
Correct |
5 ms |
1720 KB |
Output is correct |
11 |
Correct |
0 ms |
1720 KB |
Output is correct |
12 |
Correct |
7 ms |
1720 KB |
Output is correct |
13 |
Correct |
0 ms |
1720 KB |
Output is correct |
14 |
Correct |
7 ms |
1720 KB |
Output is correct |
15 |
Correct |
0 ms |
1720 KB |
Output is correct |