forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7662.cpp
More file actions
37 lines (36 loc) · 759 Bytes
/
7662.cpp
File metadata and controls
37 lines (36 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Authored by : BaaaaaaaaaaarkingDog
// Co-authored by : -
// http://boj.kr/c34ee5c887ee4ab1b913692c92ab56cc
#include <bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--){
int k;
cin >> k;
multiset<int> ms;
while(k--){
char com;
cin >> com;
if(com == 'D'){
int q;
cin >> q;
if(ms.empty()) continue;
if(q == 1) ms.erase(prev(ms.end()));
else ms.erase(ms.begin());
}
else{
int q;
cin >> q;
ms.insert(q);
}
}
if(ms.empty()) cout << "EMPTY\n";
else{
cout << *prev(ms.end()) << ' ' << *ms.begin() << '\n';
}
}
}