# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38148 | 2018-01-02T11:44:30 Z | 14kg | Weighting stones (IZhO11_stones) | C++11 | 63 ms | 7256 KB |
#include <stdio.h> #include <algorithm> #define min2(x,y) (x<y?x:y) using namespace std; int n, nn; pair<int, int> tree[3][262144]; int cnt[3], MAX[3]; void Update(int x, int y) { tree[x][y] = { tree[x][y * 2].first + tree[x][y * 2 + 1].first - min2(tree[x][y * 2].first,tree[x][y * 2 + 1].second), tree[x][y * 2].second + tree[x][y * 2 + 1].second - min2(tree[x][y * 2].first,tree[x][y * 2 + 1].second) }; if (y > 1) Update(x, y / 2); } int main() { int x, w; scanf("%d", &n); for (nn = 1; nn < n; nn *= 2); for (int i = 1; i <= n; i++) { scanf("%d %d", &x, &w); cnt[w]++, MAX[w] = MAX[w] > x ? MAX[w] : x; tree[w][nn + x - 1] = { 0,1 }, Update(w, (nn + x - 1) / 2); tree[3 - w][nn + x - 1] = { 1,0 }, Update(3 - w, (nn + x - 1) / 2); if ((cnt[1]<cnt[2] && MAX[1]>MAX[2]) || (cnt[1]>cnt[2] && MAX[1]<MAX[2])) { printf("?\n"); continue; } w = MAX[1] > MAX[2] ? 1 : 2; if (tree[w][1].first) printf("?\n"); else printf("%c\n", w == 1 ? '>' : '<'); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 7256 KB | Output is correct |
2 | Correct | 0 ms | 7256 KB | Output is correct |
3 | Correct | 0 ms | 7256 KB | Output is correct |
4 | Correct | 0 ms | 7256 KB | Output is correct |
5 | Correct | 0 ms | 7256 KB | Output is correct |
6 | Correct | 0 ms | 7256 KB | Output is correct |
7 | Correct | 0 ms | 7256 KB | Output is correct |
8 | Correct | 0 ms | 7256 KB | Output is correct |
9 | Correct | 0 ms | 7256 KB | Output is correct |
10 | Correct | 3 ms | 7256 KB | Output is correct |
11 | Correct | 56 ms | 7256 KB | Output is correct |
12 | Correct | 56 ms | 7256 KB | Output is correct |
13 | Correct | 46 ms | 7256 KB | Output is correct |
14 | Correct | 36 ms | 7256 KB | Output is correct |
15 | Correct | 53 ms | 7256 KB | Output is correct |
16 | Correct | 53 ms | 7256 KB | Output is correct |
17 | Correct | 56 ms | 7256 KB | Output is correct |
18 | Correct | 53 ms | 7256 KB | Output is correct |
19 | Correct | 49 ms | 7256 KB | Output is correct |
20 | Correct | 56 ms | 7256 KB | Output is correct |
21 | Correct | 63 ms | 7256 KB | Output is correct |
22 | Correct | 49 ms | 7256 KB | Output is correct |
23 | Correct | 53 ms | 7256 KB | Output is correct |
24 | Correct | 56 ms | 7256 KB | Output is correct |
25 | Correct | 43 ms | 7256 KB | Output is correct |