This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |