Submission #14183

#TimeUsernameProblemLanguageResultExecution timeMemory
14183ainu7볼질 (OJUZ10_ballparade)C++98
100 / 100
12 ms1716 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...