# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
17887 | Erzhann | Weighting stones (IZhO11_stones) | C++98 | 8 ms | 19300 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.
/*
/\ /\
| ).|.( |
| >-< |
=========
It's AdilkhanKo miaaaaaau
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
#define foreach(it, S) for(__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define mp make_pair
#define f first
#define s second
#define name ""
#define _ ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int MaxN = int (5e5) + 256;
const int INF = int(1e9);
const int mod = (int)(1e9) + 7;
int n, a[MaxN], m;
pair<int, int> t[4 * MaxN];
void push(int v, int l, int r){
if(a[v]){
t[v].first += a[v];
t[v].second += a[v];
if(l != r){
a[v + v] += a[v];
a[v + v + 1] += a[v];
}
a[v] = 0;
}
}
void upd(int v, int l, int r, int tl, int tr, int val){
push(v, l, r);
if(tl <= l && r <= tr){
a[v] += val;
push(v, l, r);
return;
}
if(l > tr || r < tl)
return;
int m = (l + r) / 2;
upd(v + v, l, m, tl, tr, val);
upd(v + v + 1, m + 1, r, tl, tr, val);
t[v].first = max(t[v + v].first, t[v + v + 1].first);
t[v].second = min(t[v + v].second, t[v + v + 1].second);
}
int main () { _
/* #ifdef ONLINE_JUDGE
freopen (name".in","r",stdin);
freopen (name".out","w",stdout);
#else
freopen (".in","r",stdin);
freopen (".out","w",stdout);
#endif */
cin >> n;
for(int i = 1; i <= n; i++){
int x, y; cin >> x >> y;
if(y == 1){
upd(1, 1, n, 1, x, 1);
}else{
upd(1, 1, n, 1, x, -1);
}
int mx = t[1].first;
int mn = t[1].second;
if(mn >= 0 && mx >= 0){
cout << ">" << endl;
}if(mn <= 0 && mx <= 0){
cout << "<" << endl;
}if(mn < 0 && mx > 0)
cout << "?" << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |