# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167587 | abil | Weighting stones (IZhO11_stones) | C++14 | 65 ms | 4572 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 fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
//#define int long long
using namespace std;
const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (0x3f3f3f3f);
int mx[N], mn[N], sum[N];
void push(int v,int l,int r){
if(l != r){
sum[v + v] += sum[v];
sum[v + v + 1] += sum[v];
}
mx[v] += sum[v];
mn[v] += sum[v];
sum[v] = 0;
}
void upd(int v, int tl, int tr,int l,int r, int val){
push(v, tl, tr);
if(tl > r || tr < l){
return;
}
if(l <= tl && tr <= r){
sum[v] += val;
push(v, tl, tr);
return;
}
int mid = (tl + tr) >> 1;
upd(v + v, tl, mid, l, r, val);
upd(v + v + 1, mid + 1, tr, l, r, val);
mx[v] = max(mx[v + v], mx[v + v + 1]);
mn[v] = min(mn[v + v], mn[v + v + 1]);
}
main()
{
int n, ves, side, ans;
scanf("%d", &n);
int test = n;
while(test--){
scanf("%d%d", &ves, &side);
if(side == 1){
upd(1, 1, n, 1, ves, 1);
}
else{
upd(1, 1, n, 1, ves, -1);
}
if(mx[1] >= 0 && mn[1] >= 0){
puts(">");
}
else
if(mx[1] <= 0 && mn[1] <= 0){
puts("<");
}
else{
puts("?");
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |