# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
676511 | QwertyPi | Weighting stones (IZhO11_stones) | C++14 | 176 ms | 4508 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;
const int MAXN = 1e5 + 11;
struct SegTree{
int mx[MAXN << 2], mn[MAXN << 2], s[MAXN << 2];
void add(int pos, int val, int v, int l, int r){
if(l == r){
mx[v] = mn[v] = s[v] = val;
return;
}
int m = (l + r) / 2;
if(pos <= m){
add(pos, val, v * 2 + 1, l, m);
}else{
add(pos, val, v * 2 + 2, m + 1, r);
}
s[v] = s[v * 2 + 1] + s[v * 2 + 2];
mx[v] = max(mx[v * 2 + 2], s[v * 2 + 2] + mx[v * 2 + 1]);
mn[v] = min(mn[v * 2 + 2], s[v * 2 + 2] + mn[v * 2 + 1]);
}
} segTree;
int main(){
int n; cin >> n;
for(int i = 0; i < n; i++){
int r, s; cin >> r >> s;
segTree.add(r, s == 1 ? 1 : -1, 0, 1, n);
if(segTree.mx[0] > 0 && segTree.mn[0] < 0){
cout << '?' << endl;
}else if(segTree.mx[0] > 0){
cout << '>' << endl;
}else{
cout << '<' << endl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |