CSES - HIIT Open 2018 - Results
Submission details
Task:Coins
Sender:Karhukopla
Submission time:2018-05-26 11:58:43 +0300
Language:C++
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.34 sdetails
#2ACCEPTED0.35 sdetails
#3ACCEPTED0.36 sdetails
#4ACCEPTED0.39 sdetails
#5ACCEPTED0.38 sdetails

Code

#include <bits/stdc++.h>

#define ll long long
#define lll __int128
#define pii pair<int, int>
#define M 1000000007
#define N (1<<18)
using namespace std;

int mx[2*N];
int mn[2*N];
int s[2*N];

void setv (int k, int n) {
	k += N;
	s[k] = mn[k] = mx[k] = n;
	for (k /= 2; k >= 1; k /= 2) {
		s[k] = s[2 * k] + s[2 * k + 1];
		mn[k] = min(min(mn[2 * k], s[2 * k] + mn[2 * k + 1]), s[2 * k]);
		mx[k] = max(max(mx[2 * k], s[2 * k] + mx[2 * k + 1]), s[2 * k]);
	}
}

int main () {
	int n;
	cin>>n;
	while (n --> 0) {
		int c, s;
		cin>>c>>s;
		if (s == 2) s = -1;
		setv(N - c, s);
		char ans = '-';
		if (mn[1] < 0) ans = '<';
		if (mx[1] > 0) {
			if (ans == '<') ans = '?';
			else ans = '>';
		}
		cout<<ans<<endl;
	}
}

Test details

Test 1

Verdict: ACCEPTED

input
200000
175878 1
146174 1
4939 2
181388 1
...

correct output
>
>
>
>
>
...

user output
>
>
>
>
>
...

Test 2

Verdict: ACCEPTED

input
200000
1 2
2 1
3 2
4 1
...

correct output
<
>
<
>
<
...

user output
<
>
<
>
<
...

Test 3

Verdict: ACCEPTED

input
200000
1 1
2 1
3 1
4 1
...

correct output
>
>
>
>
>
...

user output
>
>
>
>
>
...

Test 4

Verdict: ACCEPTED

input
200000
1 1
2 1
3 1
4 1
...

correct output
>
>
>
>
>
...

user output
>
>
>
>
>
...

Test 5

Verdict: ACCEPTED

input
200000
188909 2
58944 1
26824 1
143263 2
...

correct output
<
<
?
<
<
...

user output
<
<
?
<
<
...