Code Submission Evaluation System Login

CSES - HIIT Open 2018

HIIT Open 2018

Contest start:2018-05-26 11:00:00
Contest end:2018-05-26 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2018-05-26 15:51:32
2018-05-26 12:33:26
Task:Coins
Sender:KnowYourArchitecture
Submission time:2018-05-26 15:51:32
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

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";
		}
	}
}