# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74980 | Vardanyan | Weighting stones (IZhO11_stones) | C++14 | 113 ms | 15172 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.
//#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
const int N = 100*1000+7;
pair<int,int> t[4*N];
int f[4*N];
void push(int v, int s, int e) {
if (f[v]) {
t[v].first += (1*f[v]);
t[v].second += (1*f[v]);
if (s != e) {
f[v*2] += f[v];
f[v*2 + 1] += f[v];
}
f[v] = 0;
}
}
void update(int v, int s, int e, int l, int r, int val) {
push(v, s, e);
if(l>r) return;
if (s == l && e == r) {
f[v] += val;
push(v, s, e);
return;
}
int m = (s + e) / 2;
update(v*2, s, m, l, min(m,r), val);
update(v*2 + 1, m + 1, e, max(l,m+1), r, val);
push(v*2,s,m);
push(v*2+1,m+1,e);
t[v].first = max(t[v*2].first, t[v*2 + 1].first);
t[v].second = min(t[v*2].second, t[v*2 + 1].second);
}
int main(){
int n;
scanf("%d",&n);
for(int i = 1;i<=n;i++){
int r,s;
scanf("%d%d",&r,&s);
if(s == 1) update(1,1,n,1,r,1);
else update(1,1,n,1,r,-1);
if(t[1].first>0 && t[1].second<0){
printf("?\n");
continue;
}
if(t[1].first>=0 && t[1].second>=0){
printf(">\n");
continue;
}
printf("<\n");
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |