답안 #4872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4872 2014-01-06T07:10:37 Z ainta 돌 무게 재기 (IZhO11_stones) C++
100 / 100
69 ms 4156 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
#define SZ 131072
int n;
struct ST{
	int M, m, K;
}IT[SZ * 2];
void Add2(int node, int x){
	IT[node].K += x, IT[node].M += x, IT[node].m += x;
}
void Add(int node, int b, int e, int s, int l, int x){
	if (b == s && e == l){
		Add2(node, x);
		return;
	}
	Add2(node * 2, IT[node].K);
	Add2(node * 2 + 1, IT[node].K);
	IT[node].K = 0;
	int m = (b + e) >> 1;
	if (s <= m)Add(node * 2, b, m, s, min(l, m), x);
	if (l > m)Add(node * 2 + 1, m + 1, e, max(s, m + 1), l, x);
	IT[node].m = min(IT[node * 2].m, IT[node * 2 + 1].m);
	IT[node].M = max(IT[node * 2].M, IT[node * 2 + 1].M);
}
int main(){
	int i, a, b;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d%d", &a, &b);
		if (b == 1) Add(1, 1, SZ, 1, a, 1);
		else Add(1, 1, SZ, 1, a, -1);
		if (IT[1].m >= 0)printf(">\n");
		else if (IT[1].M <= 0)printf("<\n");
		else printf("?\n");
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4156 KB Output is correct - 73 tokens
2 Correct 0 ms 4156 KB Output is correct - 89 tokens
3 Correct 0 ms 4156 KB Output is correct - 221 tokens
4 Correct 0 ms 4156 KB Output is correct - 21 tokens
5 Correct 0 ms 4156 KB Output is correct - 369 tokens
6 Correct 0 ms 4156 KB Output is correct - 492 tokens
7 Correct 0 ms 4156 KB Output is correct - 945 tokens
8 Correct 0 ms 4156 KB Output is correct - 1237 tokens
9 Correct 0 ms 4156 KB Output is correct - 1105 tokens
10 Correct 6 ms 4156 KB Output is correct - 8921 tokens
11 Correct 35 ms 4156 KB Output is correct - 56110 tokens
12 Correct 61 ms 4156 KB Output is correct - 90207 tokens
13 Correct 50 ms 4156 KB Output is correct - 100000 tokens
14 Correct 56 ms 4156 KB Output is correct - 100000 tokens
15 Correct 56 ms 4156 KB Output is correct - 100000 tokens
16 Correct 55 ms 4156 KB Output is correct - 100000 tokens
17 Correct 57 ms 4156 KB Output is correct - 100000 tokens
18 Correct 61 ms 4156 KB Output is correct - 99999 tokens
19 Correct 60 ms 4156 KB Output is correct - 99999 tokens
20 Correct 57 ms 4156 KB Output is correct - 99999 tokens
21 Correct 61 ms 4156 KB Output is correct - 100000 tokens
22 Correct 58 ms 4156 KB Output is correct - 100000 tokens
23 Correct 60 ms 4156 KB Output is correct - 100000 tokens
24 Correct 62 ms 4156 KB Output is correct - 100000 tokens
25 Correct 69 ms 4156 KB Output is correct - 100000 tokens