# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894968 | Andrey | Weighting stones (IZhO11_stones) | C++14 | 42 ms | 7264 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |