제출 #1325254

#제출 시각아이디문제언어결과실행 시간메모리
1325254djsksbrbfInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
32 ms3548 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
#define fi first
#define se second
#define pb push_back
const int MOD = 1e9 + 7;
const int MAX = 5e5 + 5;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
#define int ll

signed main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   
   int n, q; cin >> n >> q;
   
   int ans = 0;
   int prev[n + 5], pos[n + 5];
   while(q--){
      int x; cin >> x;
      
      if(x > 0){
         if(pos[x] == 1 && prev[x] == ans){
            prev[x]++;
            ans++;
            pos[x] = 1;
         }
         else{
            pos[x] = 1;
            prev[x] = ans;
         }
      }
      else{
         x = -x;
         pos[x] = 0;
         prev[x] = ans;
      }
   }
   cout << ans << endl;
   
   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...