Submission #133809

# Submission time Handle Problem Language Result Execution time Memory
133809 2019-07-21T12:57:35 Z mirbek01 Weighting stones (IZhO11_stones) C++11
100 / 100
385 ms 4556 KB
# include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 2;

int n, mn[N * 4], mx[N * 4], b[N * 4];

void push(int v, int tl, int tr){
	if(tl != tr){
		b[v << 1] += b[v];
		b[v << 1 | 1] += b[v];
	}
	mx[v] += b[v];
	mn[v] += b[v];
	b[v] = 0;
}

void upd(int l, int r, int val, int v = 1, int tl = 1, int tr = n){
	push(v, tl, tr);
	if(l > tr || tl > r) 
		return ;
	if(l <= tl && tr <= r){
		b[v] += val;
		push(v, tl, tr);
		return ;
	}
	int tm = (tl + tr) >> 1;
	upd(l, r, val, v << 1, tl, tm);
	upd(l, r, val, v << 1 | 1, tm + 1, tr);
	mx[v] = max(mx[v << 1], mx[v << 1 | 1]);
	mn[v] = min(mn[v << 1], mn[v << 1 | 1]);
}

int main(){
	cin >> n;

	for(int i = 1; i <= n; i ++){
		int tp, x;
		cin >> x >> tp;
		if(tp == 1){
			upd(1, x, 1);
		} else {
			upd(1, x, -1);
		}
		if(mx[1] >= 0 && mn[1] >= 0)
			puts(">");
		else if(mx[1] <= 0 && mn[1] <= 0)
			puts("<");
		else 
			puts("?");
	}
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 6 ms 376 KB Output is correct
10 Correct 34 ms 760 KB Output is correct
11 Correct 218 ms 2448 KB Output is correct
12 Correct 358 ms 4320 KB Output is correct
13 Correct 381 ms 4428 KB Output is correct
14 Correct 379 ms 4524 KB Output is correct
15 Correct 380 ms 4472 KB Output is correct
16 Correct 381 ms 4432 KB Output is correct
17 Correct 378 ms 4556 KB Output is correct
18 Correct 383 ms 4452 KB Output is correct
19 Correct 378 ms 4344 KB Output is correct
20 Correct 378 ms 4468 KB Output is correct
21 Correct 380 ms 4476 KB Output is correct
22 Correct 382 ms 4500 KB Output is correct
23 Correct 379 ms 4344 KB Output is correct
24 Correct 385 ms 4408 KB Output is correct
25 Correct 380 ms 4344 KB Output is correct