Code Submission Evaluation System Login

HIIT Open 2018

Start:2018-05-26 11:00:00
End:2018-05-26 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2018 - Results
History
2018-05-26 11:53:26
Task:Coins
Sender:Ukkonen Fan Club
Submission time:2018-05-26 11:53:26
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.45 / 1.00details
#2ACCEPTED0.43 / 1.00details
#3ACCEPTED0.47 / 1.00details
#4ACCEPTED0.45 / 1.00details
#5ACCEPTED0.47 / 1.00details

Code

#include <iostream>

const int N = 2 * 1e5;
int min[4 * N];
int max[4 * N];
int add[4 * N];
int h = 1;

void push(int i) {
	min[i] += add[i];
	max[i] += add[i];
	if (i < h) {
		add[2*i] += add[i];
		add[2*i+1] += add[i];
	}
	add[i] = 0;
}
void update(int i) {
	min[i] = std::min(min[2*i], min[2*i+1]);
	max[i] = std::max(max[2*i], max[2*i+1]);
}

void inc(int a, int b, int v, int i = 1, int ia = 0, int ib = h - 1) {
	push(i);
	if (b < ia || ib < a) return;
	if (a <=ia && ib<= b) {
		add[i] += v;
		push(i);
	} else {
		int mid = (ia + ib) >> 1;
		inc(a, b, v, 2 * i, ia, mid);
		inc(a, b, v, 2 * i + 1, mid + 1, ib);
		update(i);
	}
}

int main() {
	int n;
	std::cin >> n;
	while(h < n) h <<= 1;
	for (int i = 0; i < n; ++i) {
		int a, b;
		std::cin >> a >> b;
		a = (n - a);
		int v = (b == 1 ? 1 : -1);
		inc(a, n - 1, v);
		if (min[1] >= 0) {
			std::cout << ">\n";
		} else if (max[1] <= 0) {
			std::cout << "<\n";
		} else {
			std::cout << "?\n";
		}
	}
}

Test details

Test 1

Verdict: ACCEPTED

input
200000
175878 1
146174 1
4939 2
181388 1
27963 2
28393 1
101955 2
129380 1
53446 1
56883 2
41641 2
52574 1
185690 2
17672 2
187 2
29223 1
116434 2
81263 2
153912 2
...
view   save

correct output
>
>
>
>
>
>
>
>
>
>
>
>
?
?
?
?
?
?
?
?
...
view   save

user output
>
>
>
>
>
>
>
>
>
>
>
>
?
?
?
?
?
?
?
?
...
view   save

Test 2

Verdict: ACCEPTED

input
200000
1 2
2 1
3 2
4 1
5 2
6 1
7 2
8 1
9 2
10 1
11 2
12 1
13 2
14 1
15 2
16 1
17 2
18 1
19 2
...
view   save

correct output
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
...
view   save

user output
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
...
view   save

Test 3

Verdict: ACCEPTED

input
200000
1 1
2 1
3 1
4 1
5 1
6 2
7 2
8 2
9 2
10 2
11 1
12 1
13 1
14 1
15 1
16 2
17 2
18 2
19 2
...
view   save

correct output
>
>
>
>
>
?
?
?
?
<
?
?
?
?
>
?
?
?
?
<
...
view   save

user output
>
>
>
>
>
?
?
?
?
<
?
?
?
?
>
?
?
?
?
<
...
view   save

Test 4

Verdict: ACCEPTED

input
200000
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
...
view   save

correct output
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
...
view   save

user output
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
...
view   save

Test 5

Verdict: ACCEPTED

input
200000
188909 2
58944 1
26824 1
143263 2
108129 2
170746 1
129857 2
151652 1
92616 1
5122 1
85017 2
133713 2
130510 1
23167 2
55879 2
81852 1
117028 1
185678 1
5335 2
...
view   save

correct output
<
<
?
<
<
<
<
?
?
?
?
?
?
?
?
?
?
?
?
?
...
view   save

user output
<
<
?
<
<
<
<
?
?
?
?
?
?
?
?
?
?
?
?
?
...
view   save