# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167500 | Toirov_Sadi | Weighting stones (IZhO11_stones) | C++17 | 332 ms | 4616 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 se second
using namespace std;
const long long N = 1e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
int n;
int mn[4 * N];
int mx[4 * N];
int lazy[4 * N];
void push(int v, int tl, int tr){
if(tl != tr){
lazy[v * 2] += lazy[v];
lazy[v * 2 + 1] += lazy[v];
}
mx[v] += lazy[v];
mn[v] += lazy[v];
lazy[v] = 0;
}
void upd(int v, int tl, int tr, int l, int r, int x){
push(v, tl, tr);
if(l > r){
return;
}
if(tl == l && tr == r){
lazy[v] += x;
push(v, tl, tr);
return;
}
int tm = (tl + tr) / 2;
upd(v * 2, tl, tm, l, min(r, tm), x);
upd(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, x);
mx[v] = max(mx[v * 2], mx[v * 2 + 1]);
mn[v] = min(mn[v * 2], mn[v * 2 + 1]);
}
int main()
{
/// freopen("input.txt", "r", stdin);
/// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio( false );
cin >> n;
for(int i = 1; i <= n; i ++){
int x, t;
cin >> x >> t;
if(t == 1){
upd(1, 1, n, 1, x, 1);
}
else{
upd(1, 1, n, 1, x, -1);
}
if(mx[1] >= 0 && mn[1] >= 0){
cout << ">\n";
}
else if(mx[1] <= 0 && mn[1] <= 0){
cout << "<\n";
}
else{
cout << "?\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |