-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicpc7662.cpp
More file actions
35 lines (34 loc) · 807 Bytes
/
icpc7662.cpp
File metadata and controls
35 lines (34 loc) · 807 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
#include <iostream>
#include <set>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int T;
cin >> T;
for(int testcase = 0; testcase < T; testcase++){
int n;
multiset<int> dpq;
cin >> n;
for(int i = 0; i < n; i++){
int k;
char cmd;
cin >> cmd >> k;
if(cmd == 'I')
dpq.insert(k);
else if(dpq.size()){
if(k == 1)
dpq.erase(--dpq.end());
else
dpq.erase(dpq.begin());
}
}
if(dpq.size())
cout << *dpq.rbegin() << ' ' << *dpq.begin();
else
cout << "EMPTY";
cout << '\n';
}
return 0;
}