Task: | Coins |
Sender: | KnowYourArchitecture |
Submission time: | 2018-05-26 15:51:32 +0300 |
Language: | C++ |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.94 s | details |
#2 | TIME LIMIT EXCEEDED | -- | details |
#3 | TIME LIMIT EXCEEDED | -- | details |
#4 | ACCEPTED | 0.39 s | details |
#5 | ACCEPTED | 0.64 s | details |
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: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 2 1 3 2 4 1 ... |
correct output |
---|
< > < > < ... |
user output |
---|
(empty) |
Test 3
Verdict: TIME LIMIT EXCEEDED
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 |
---|
< < ? < < ... |