#include <iostream>
using namespace std;
int score;
bool base[3];
void go() {
if(base[0]) {
if(base[1]) {
if(base[2]) {
score++;
base[0] = false;
}
else {
base[2] = true;
base[0] = false;
}
}
else {
base[1] = true;
base[0] = false;
}
}
}
void go_all() {
if(base[2]) {
score++;
base[2] = false;
}
for(int i = 1; i >= 0; i--) {
if(base[i]) {
base[i + 1] = true;
base[i] = false;
}
}
}
int main() {
int n, b, ballcount = 0;
cin >> n;
for(; n--;) {
cin >> b;
if(b == 3) {
go_all();
}
if(b != 2) {
ballcount++;
if(ballcount == 4) {
ballcount = 0;
go();
base[0] = true;
}
}
else {
ballcount = 0;
go();
base[0] = true;
}
}
cout << score;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1716 KB |
Output is correct |
2 |
Correct |
9 ms |
1716 KB |
Output is correct |
3 |
Correct |
0 ms |
1716 KB |
Output is correct |
4 |
Correct |
0 ms |
1716 KB |
Output is correct |
5 |
Correct |
0 ms |
1716 KB |
Output is correct |
6 |
Correct |
0 ms |
1716 KB |
Output is correct |
7 |
Correct |
0 ms |
1716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1716 KB |
Output is correct |
2 |
Correct |
0 ms |
1716 KB |
Output is correct |
3 |
Correct |
0 ms |
1716 KB |
Output is correct |
4 |
Correct |
0 ms |
1716 KB |
Output is correct |
5 |
Correct |
0 ms |
1716 KB |
Output is correct |
6 |
Correct |
3 ms |
1716 KB |
Output is correct |
7 |
Correct |
12 ms |
1716 KB |
Output is correct |
8 |
Correct |
13 ms |
1716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1716 KB |
Output is correct |
2 |
Correct |
9 ms |
1716 KB |
Output is correct |
3 |
Correct |
0 ms |
1716 KB |
Output is correct |
4 |
Correct |
0 ms |
1716 KB |
Output is correct |
5 |
Correct |
12 ms |
1716 KB |
Output is correct |
6 |
Correct |
11 ms |
1716 KB |
Output is correct |
7 |
Correct |
7 ms |
1716 KB |
Output is correct |
8 |
Correct |
9 ms |
1716 KB |
Output is correct |
9 |
Correct |
0 ms |
1716 KB |
Output is correct |
10 |
Correct |
12 ms |
1716 KB |
Output is correct |
11 |
Correct |
1 ms |
1716 KB |
Output is correct |
12 |
Correct |
0 ms |
1716 KB |
Output is correct |
13 |
Correct |
13 ms |
1716 KB |
Output is correct |
14 |
Correct |
13 ms |
1716 KB |
Output is correct |
15 |
Correct |
13 ms |
1716 KB |
Output is correct |