Submission #17886

# Submission time Handle Problem Language Result Execution time Memory
17886 2016-01-13T05:30:19 Z Erzhann Weighting stones (IZhO11_stones) C++
36 / 100
5 ms 8752 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 (2e5) + 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 */
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x, y; cin >> 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){
			cout << ">" << endl;
		}if(mn <= 0 && mx <= 0){
			cout << "<" << endl;
		}if(mn < 0 && mx > 0) 
			cout << "?" << endl;
	}                       	
return 0;
}                   									
# Verdict Execution time Memory Grader output
1 Correct 0 ms 8752 KB Output is correct - 73 tokens
2 Correct 0 ms 8752 KB Output is correct - 89 tokens
3 Correct 0 ms 8752 KB Output is correct - 221 tokens
4 Correct 0 ms 8752 KB Output is correct - 21 tokens
5 Correct 0 ms 8752 KB Output is correct - 369 tokens
6 Correct 0 ms 8752 KB Output is correct - 492 tokens
7 Correct 0 ms 8752 KB Output is correct - 945 tokens
8 Correct 3 ms 8752 KB Output is correct - 1237 tokens
9 Correct 0 ms 8752 KB Output is correct - 1105 tokens
10 Runtime error 3 ms 8752 KB writev (syscall #20) was called by the program (disallowed syscall)
11 Runtime error 2 ms 8752 KB writev (syscall #20) was called by the program (disallowed syscall)
12 Runtime error 0 ms 8752 KB SIGSEGV Segmentation fault
13 Runtime error 2 ms 8752 KB writev (syscall #20) was called by the program (disallowed syscall)
14 Runtime error 5 ms 8752 KB writev (syscall #20) was called by the program (disallowed syscall)
15 Runtime error 3 ms 8752 KB writev (syscall #20) was called by the program (disallowed syscall)
16 Runtime error 4 ms 8752 KB writev (syscall #20) was called by the program (disallowed syscall)
17 Runtime error 0 ms 8752 KB SIGSEGV Segmentation fault
18 Runtime error 2 ms 8752 KB SIGSEGV Segmentation fault
19 Runtime error 0 ms 8752 KB SIGSEGV Segmentation fault
20 Runtime error 2 ms 8752 KB SIGSEGV Segmentation fault
21 Runtime error 0 ms 8752 KB SIGSEGV Segmentation fault
22 Runtime error 2 ms 8752 KB SIGSEGV Segmentation fault
23 Runtime error 2 ms 8752 KB SIGSEGV Segmentation fault
24 Runtime error 2 ms 8752 KB SIGSEGV Segmentation fault
25 Runtime error 0 ms 8752 KB SIGSEGV Segmentation fault