# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
337780 | beksultan04 | Weighting stones (IZhO11_stones) | C++14 | 76 ms | 7020 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;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int pus[N];
pii der[N];
void push(int v,int l,int r){
der[v].fr += pus[v];
der[v].sc += pus[v];
if (l != r){
pus[v<<1]+=pus[v];
pus[(v<<1)+1]+=pus[v];
}
pus[v]=0;
}
void update(int v,int l,int r,int ql,int qr,int x){
push(v,l,r);
if (ql > r || l > qr)ret ;
if (ql <= l && r <= qr){
pus[v]+=x;
push(v,l,r);
ret ;
}
int m = (l+r)>>1;
update(v<<1,l,m,ql,qr,x);
update((v<<1)+1,m+1,r,ql,qr,x);
der[v].fr = min(der[v<<1].fr,der[(v<<1)+1].fr);
der[v].sc = max(der[v<<1].sc,der[(v<<1)+1].sc);
}
main(){
int n,i;
scan1(n)
i=n;
while (i--){
int a,b;
scan2(a,b)
if (b == 1){
update(1,1,n,1,a,-1);
}
else {
update(1,1,n,1,a,1);
}
if (der[1].fr >= 0){
cout <<"<\n";
}
else if (der[1].sc <= 0){
cout <<">\n";
}
else cout <<"?\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |