제출 #1346590

#제출 시각아이디문제언어결과실행 시간메모리
1346590julia_08Infinite Race (EGOI24_infiniterace2)C++20
100 / 100
12 ms1732 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10;

bool behind[MAXN];

int main(){
  cin.tie(0)->sync_with_stdio(0);

  int n; cin >> n;

  int ans = 0;

  int q; cin >> q;

  for(int i=1; i<n; i++) behind[i] = false;

  vector<int> cur; // cur guarda quem tem behind[i] = true

  while(q--){

    int x; cin >> x;

    if(x > 0){

      if(behind[x]){

        ans ++;

        for(auto y : cur) behind[y] = false;
        cur.clear();
      
      }

      behind[x] = true;
      cur.push_back(x);

    } else behind[-x] = false;

  }

  cout << ans << "\n";

  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...