Submission #17718

#TimeUsernameProblemLanguageResultExecution timeMemory
17718AdilkhanWeighting stones (IZhO11_stones)C++98
100 / 100
80 ms23220 KiB
#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 timeMemoryGrader output
Fetching results...