CSES - HIIT Open 2018 - Results
Submission details
Task:Coins
Sender:KnowYourArchitecture
Submission time:2018-05-26 15:51:32 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.94 sdetails
#2--details
#3--details
#4ACCEPTED0.39 sdetails
#5ACCEPTED0.64 sdetails

Code

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

int main() {
	int n;
	cin >> n;
	set<int> stacks[2];
	stacks[0].insert(-1);
	stacks[1].insert(-1);
	for (int i = 0; i < n; i++) {
		int c, s;
		cin >> c >> s;
		s--;
		stacks[s].insert(c);
		auto it1 = stacks[0].rbegin();
		auto it2 = stacks[1].rbegin();
		if (*it1 > *it2) {
			// Stack 1 can be bigger
			bool res = true;
			while (it1 != stacks[0].rend() && it2 != stacks[1].rend()) {
				if (*it1 < *it2) {res = false;break;}
				it1++;
				it2++;
			}
			if (it2 != stacks[1].rend()) res = false;
			if (res) cout << ">\n";
			else cout << "?\n";
		} else {
			// Stack 2 can be bigger
			bool res = true;
			while (it1 != stacks[0].rend() && it2 != stacks[1].rend()) {
				if (*it1 > *it2) {res = false;break;}
				it1++;
				it2++;
			}
			if (it1 != stacks[0].rend()) res = false;
			if (res) cout << "<\n";
			else cout << "?\n";
		}
	}
}

Test details

Test 1

Verdict: ACCEPTED

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

correct output
>
>
>
>
>
...

user output
>
>
>
>
>
...

Test 2

Verdict:

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

correct output
<
>
<
>
<
...

user output
(empty)

Test 3

Verdict:

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

correct output
>
>
>
>
>
...

user output
(empty)

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
<
<
?
<
<
...