Submission #1113410

# Submission time Handle Problem Language Result Execution time Memory
1113410 2024-11-16T14:33:18 Z Chinguun Weighting stones (IZhO11_stones) C++14
100 / 100
34 ms 7676 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define meta int m = (L + R) / 2, x = i * 2 + 1, y = x + 1

const int N = 4e5 + 7;

int s[N], mx[N], mn[N];

void update (int i, int L, int R, int k, int v) {
	if (L == R) {
		s[i] = mx[i] = mn[i] = v;
		return;
	}
	meta;
	if (k <= m) update (x, L, m, k, v);
	else update (y, m + 1, R, k, v);
	s[i] = s[x] + s[y];
	mn[i] = min (mn[x] + s[y], mn[y]);
	mx[i] = max (mx[x] + s[y], mx[y]); 
	return;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		int x, y; cin >> x >> y; x--;
		if (y == 1) update (0, 0, n - 1, x, 1);
		else update (0, 0, n - 1, x, -1);

		if (mx[0] <= 0) cout << '<';
		else if (mn[0] >= 0) cout << '>';
		else cout << '?';
		cout << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 4 ms 1104 KB Output is correct
11 Correct 18 ms 4068 KB Output is correct
12 Correct 34 ms 7472 KB Output is correct
13 Correct 29 ms 7496 KB Output is correct
14 Correct 27 ms 7504 KB Output is correct
15 Correct 28 ms 7676 KB Output is correct
16 Correct 28 ms 7496 KB Output is correct
17 Correct 30 ms 7516 KB Output is correct
18 Correct 28 ms 7496 KB Output is correct
19 Correct 29 ms 7540 KB Output is correct
20 Correct 28 ms 7492 KB Output is correct
21 Correct 28 ms 7516 KB Output is correct
22 Correct 28 ms 7496 KB Output is correct
23 Correct 28 ms 7504 KB Output is correct
24 Correct 29 ms 7504 KB Output is correct
25 Correct 28 ms 7464 KB Output is correct