Submission #1241388

#TimeUsernameProblemLanguageResultExecution timeMemory
1241388dxh074Infinite Race (EGOI24_infiniterace2)C++20
29 / 100
9 ms2116 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n, q, x, ans = 0; cin >> n >> q; ll a[n]{}; bool b[n]{}; while(q--) { cin >> x; if (x < 0) { b[-x] = false; a[-x] = max(a[-x], ans); } else { a[x] = max(a[x], ans-1); if (b[x]) { a[x]++; ans = max(ans, a[x]); } b[x] = true; } } 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...