Submission #676511

#TimeUsernameProblemLanguageResultExecution timeMemory
676511QwertyPiWeighting stones (IZhO11_stones)C++14
100 / 100
176 ms4508 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 11; struct SegTree{ int mx[MAXN << 2], mn[MAXN << 2], s[MAXN << 2]; void add(int pos, int val, int v, int l, int r){ if(l == r){ mx[v] = mn[v] = s[v] = val; return; } int m = (l + r) / 2; if(pos <= m){ add(pos, val, v * 2 + 1, l, m); }else{ add(pos, val, v * 2 + 2, m + 1, r); } s[v] = s[v * 2 + 1] + s[v * 2 + 2]; mx[v] = max(mx[v * 2 + 2], s[v * 2 + 2] + mx[v * 2 + 1]); mn[v] = min(mn[v * 2 + 2], s[v * 2 + 2] + mn[v * 2 + 1]); } } segTree; int main(){ int n; cin >> n; for(int i = 0; i < n; i++){ int r, s; cin >> r >> s; segTree.add(r, s == 1 ? 1 : -1, 0, 1, n); if(segTree.mx[0] > 0 && segTree.mn[0] < 0){ cout << '?' << endl; }else if(segTree.mx[0] > 0){ cout << '>' << endl; }else{ cout << '<' << endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...