답안 #17888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17888 2016-01-13T05:35:40 Z Erzhann 돌 무게 재기 (IZhO11_stones) C++
100 / 100
73 ms 19308 KB
/*
  /\     /\
  | ).|.( |
  |  >-<  |
  =========
It's AdilkhanKo miaaaaaau      
*/
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define endl "\n"
#define foreach(it, S) for(__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define mp make_pair
#define f first
#define s second 
#define name ""
#define _ ios_base::sync_with_stdio(false);cin.tie(0);

using namespace std;
                                            
const int MaxN = int (5e5) + 256;
const int INF = int(1e9);  
const int mod = (int)(1e9) + 7;
int n, a[MaxN], m;
pair<int, int> t[4 * MaxN];

void push(int v, int l, int r){
	if(a[v]){
		t[v].first += a[v];
		t[v].second += a[v];
		if(l != r){
			a[v + v] += a[v];
			a[v + v + 1] += a[v];
		}
		a[v] = 0;
	}
}
void upd(int v, int l, int r, int tl, int tr, int val){
	push(v, l, r);
	if(tl <= l && r <= tr){
		a[v] += val;
		push(v, l, r);
		return;
	}
	if(l > tr || r < tl)
		return;
	int m = (l + r) / 2;
	upd(v + v, l, m, tl, tr, val);
	upd(v + v + 1, m + 1, r, tl, tr, val);
	t[v].first = max(t[v + v].first, t[v + v + 1].first);
	t[v].second = min(t[v + v].second, t[v + v + 1].second);
}
int main () {
/*	#ifdef ONLINE_JUDGE
		freopen (name".in","r",stdin);
		freopen (name".out","w",stdout);
	#else
		freopen (".in","r",stdin);
		freopen (".out","w",stdout);
	#endif */
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){    
		int x, y; scanf("%d%d", &x, &y);
		if(y == 1){
			upd(1, 1, n, 1, x, 1);
		}else{
			upd(1, 1, n, 1, x, -1);
		}
		int mx = t[1].first;
		int mn = t[1].second;
		if(mn >= 0 && mx >= 0){
			puts(">");
		}if(mn <= 0 && mx <= 0){
			puts("<");
		}if(mn < 0 && mx > 0) 
			puts("?");
	}                       	
return 0;
}                   									
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 19308 KB Output is correct - 73 tokens
2 Correct 5 ms 19308 KB Output is correct - 89 tokens
3 Correct 0 ms 19308 KB Output is correct - 221 tokens
4 Correct 0 ms 19308 KB Output is correct - 21 tokens
5 Correct 0 ms 19308 KB Output is correct - 369 tokens
6 Correct 0 ms 19308 KB Output is correct - 492 tokens
7 Correct 0 ms 19308 KB Output is correct - 945 tokens
8 Correct 0 ms 19308 KB Output is correct - 1237 tokens
9 Correct 5 ms 19308 KB Output is correct - 1105 tokens
10 Correct 7 ms 19308 KB Output is correct - 8921 tokens
11 Correct 37 ms 19308 KB Output is correct - 56110 tokens
12 Correct 72 ms 19308 KB Output is correct - 90207 tokens
13 Correct 69 ms 19308 KB Output is correct - 100000 tokens
14 Correct 71 ms 19308 KB Output is correct - 100000 tokens
15 Correct 68 ms 19308 KB Output is correct - 100000 tokens
16 Correct 71 ms 19308 KB Output is correct - 100000 tokens
17 Correct 73 ms 19308 KB Output is correct - 100000 tokens
18 Correct 63 ms 19308 KB Output is correct - 99999 tokens
19 Correct 70 ms 19308 KB Output is correct - 99999 tokens
20 Correct 61 ms 19308 KB Output is correct - 99999 tokens
21 Correct 68 ms 19308 KB Output is correct - 100000 tokens
22 Correct 62 ms 19308 KB Output is correct - 100000 tokens
23 Correct 68 ms 19308 KB Output is correct - 100000 tokens
24 Correct 70 ms 19308 KB Output is correct - 100000 tokens
25 Correct 65 ms 19308 KB Output is correct - 100000 tokens