# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168147 | GioChkhaidze | Weighting stones (IZhO11_stones) | C++14 | 77 ms | 7548 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 Tree int h,int l,int r
#define Left 2*h,l,(l+r)/2
#define Right 2*h+1,(l+r)/2+1,r
#define ll long long
using namespace std;
const int N=1e5+5;
ll n,L,R,idx,type,dl;
typedef struct {ll m1; ll m2; ll add; } Node;
Node v[4*N];
void Shift(Tree) {
v[h].m1+=v[h].add;
v[h].m2+=v[h].add;
if (l!=r) {
v[2*h].add+=v[h].add;
v[2*h+1].add+=v[h].add;
}
v[h].add=0;
}
void Upd(Tree) {
Shift(h,l,r);
if (r<L || R<l) return ;
if (L<=l && r<=R) {
v[h].add+=dl;
Shift(h,l,r);
return ;
}
Upd(Left),Upd(Right);
v[h].m1=min(v[2*h].m1,v[2*h+1].m1);
v[h].m2=max(v[2*h].m2,v[2*h+1].m2);
}
main () {
scanf("%d",&n);
for (int i=1; i<=n; i++) {
scanf("%d%d",&idx,&type);
if (type==1) {
L=1,R=idx,dl=1;
Upd(1,1,n);
}
else {
L=1,R=idx,dl=-1;
Upd(1,1,n);
}
if (v[1].m1>=0 && v[1].m2>=0) printf(">\n");
else
if (v[1].m1<=0 && v[1].m2<=0) printf("<\n");
else printf("?\n");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |