# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166413 | Dovran | Weighting stones (IZhO11_stones) | C++11 | 499 ms | 5628 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>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long
using namespace std;
int n, v[4*N][3], c[4*N];
void upd(int nd, int l, int r, int x, int y){
if(v[nd/2][2]!=0)
v[nd][2]+=v[nd/2][2], v[nd][1]+=v[nd/2][2], c[nd]+=v[nd/2][2];
if(l>x)
return;
if(r<=x){
v[nd][2]+=y;
v[nd][1]+=y, c[nd]+=y;
return;
}
int md=(l+r)/2;
upd(nd*2, l, md, x, y);
upd(nd*2+1, md+1, r, x, y);
v[nd][1]=max(v[nd*2][1], v[nd*2+1][1]);
c[nd]=min(c[nd*2], c[nd*2+1]);
v[nd][2]=0;
}
int main(){
cin>>n;
for(int i=1; i<=n; i++){
int x, y;
cin>>x>>y;
if(y==1)
upd(1, 1, n, x, -1);
else
upd(1, 1, n, x, 1);
if (v[1][1] <= 0)
cout<<">\n";
else if (c[1] >= 0)
cout<<"<\n";
else
cout<<"?\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |