# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
38148 | 14kg | 돌 무게 재기 (IZhO11_stones) | C++11 | 63 ms | 7256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ? '>' : '<');
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |