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 <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main()
{
int N;
cin >> N;
int res = 0;
int b1 = 0, b2 = 0, b3 = 0;
int cnt = 0;
for (int i=0; i<N; i++) {
int type;
cin >> type;
if (type == 1) {
cnt ++;
if (cnt == 4) {
cnt = 0;
type = 2;
}
}
if (type == 2) {
cnt = 0;
b1 ++;
if (b1 == 2) {
b1 --;
b2 ++;
if (b2 == 2) {
b2 --;
b3 ++;
if (b3 == 2) {
b3 --;
res ++;
}
}
}
}
if (type == 3) {
res += b3;
b3 = b2;
b2 = b1;
b1 = 0;
cnt ++;
if (cnt == 4) {
b1 = 1;
cnt = 0;
}
}
}
cout << res << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |