Submission #894968

#TimeUsernameProblemLanguageResultExecution timeMemory
894968AndreyWeighting stones (IZhO11_stones)C++14
100 / 100
42 ms7264 KiB
#include<bits/stdc++.h> using namespace std; vector<int> sm(500001); vector<int> big(500001); vector<int> wow(500001); void upd(int l, int r, int ql, int qr, int x, int a) { if(l == ql && r == qr) { sm[x]+=a; big[x]+=a; wow[x]+=a; return; } int m = (l+r)/2; if(qr <= m) { upd(l,m,ql,qr,x*2,a); } else if(ql > m) { upd(m+1,r,ql,qr,x*2+1,a); } else { upd(l,m,ql,m,x*2,a); upd(m+1,r,m+1,qr,x*2+1,a); } big[x] = max(big[x*2],big[x*2+1])+wow[x]; sm[x] = min(sm[x*2],sm[x*2+1])+wow[x]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,a,b; cin >> n; for(int i = 1; i <= n; i++) { cin >> a >> b; a = n-a+1; if(b == 1) { upd(1,n,a,n,1,1); } else { upd(1,n,a,n,1,-1); } if(sm[1] >= 0) { cout << ">\n"; } else if(big[1] <= 0) { cout << "<\n"; } else { cout << "?\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...