제출 #1221507

#제출 시각아이디문제언어결과실행 시간메모리
1221507gry3125Infinite Race (EGOI24_infiniterace2)C++20
63 / 100
40 ms1864 KiB
#include <bits/stdc++.h> #define f0r(i,n) for(int i=0;i<n;i++) typedef long long int ll; using namespace std; int main() { int n, q; cin >> n >> q; map<int,int> idx; int mx = 0; vector<int> cnt(n, -1), cur(n); while (q--) { int a; cin >> a; if (cur[abs(a)] == 0) { if (a > 0) cur[abs(a)] = 1; else cur[abs(a)] = -1; cnt[abs(a)] = max(mx, cnt[abs(a)]+1); mx = cnt[abs(a)]; continue; } if (cur[abs(a)] == 1 && a > 0) { cnt[a] = max(mx, cnt[abs(a)]+1); mx = cnt[abs(a)]; } if (a > 0) cur[abs(a)] = 1; else cur[abs(a)] = -1; } cout << mx; 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...