Submission #1267493

#TimeUsernameProblemLanguageResultExecution timeMemory
1267493nekolieInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
37 ms2048 KiB
// Suzune, if you want to ascend to a higher class, struggle with every ounce of strenght you have. #include <bits/stdc++.h> using namespace std; const int baza = (1<<18); int n,q,x, d[2*baza], odp; void push(int v) { d[2*v] = max(d[2*v],d[v]), d[2*v+1] = max(d[2*v+1],d[v]), d[v] = 0; } int value(int i) { int w = 0; i += baza; while (i > 0) w = max(w,d[i]), i >>= 1; return w; } void ustaw(int i, int val) { int v = 1; for (int j = 17; j >= 0; j--) push(v), v = ((i&(1<<j)) ? 2*v+1 : 2*v); d[v] = val; } void reset(int l, int r) { l += baza-1, r += baza+1; while (l/2 != r/2) { if ((l&1) == 0) d[l+1] = 2; if ((r&1) == 1) d[r-1] = 2; l >>= 1, r >>= 1; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q; for (int i = 1; i < n; i++) d[i+baza] = 1; for (int i = 0; i < q; i++) { cin >> x; if (x > 0) { if (value(x) > 0) ustaw(x,0); else odp++, reset(0,x-1), reset(x+1,baza-1); } else ustaw(-x,1); } cout << odp << 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...