# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17718 | Adilkhan | Weighting stones (IZhO11_stones) | C++98 | 80 ms | 23220 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 pb push_back
#define endl "\n"
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fname ""
#define sz(x) (int)(x.size())
typedef long long ll;
using namespace std;
const ll N = (ll)(5e5) + 322;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;
int n, x[N], y[N], q, s, sum, mn, mx;
int add[N];
pair <int, int> t[N * 4];
void push(int x, int l, int r) {
if (add[x]) {
t[x].fi += add[x];
t[x].se += add[x];
if (l != r) {
add[x + x] += add[x];
add[x + x + 1] += add[x];
}
add[x] = 0;
}
}
void upd(int x, int tl, int tr, int l, int r, int val) {
push(x, tl, tr);
if (l <= tl && tr <= r) {
add[x] += val;
push(x, tl, tr);
return;
}
if (tl > r || tr < l) {
return;
}
int mid = (tl + tr) / 2;
upd(x + x, tl, mid, l, r, val);
upd(x + x + 1, mid + 1, tr, l, r, val);
t[x].fi = max(t[x + x].fi, t[x + x + 1].fi);
t[x].se = min(t[x + x].se, t[x + x + 1].se);
}
int main () {
//freopen(fname".in", "r", stdin);
//freopen(fname".out", "w", stdout);
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", &q, &s);
if (s == 1) {
upd(1, 1, n, 1, q, 1);
}else {
upd(1, 1, n, 1, q, -1);
}
mx = t[1].fi;
mn = t[1].se;
if (mn < 0 && mx > 0) {
puts("?");
}
if (mn >= 0 && mx >= 0) {
puts(">");
}
if (mn <= 0 && mx <= 0) {
puts("<");
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |