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 38 39 40 41 42 43 44 45 46 47 | // //SKKU IDIOT LHS // #include <bits/stdc++.h> #define ___ ios_base::sync_with_stdio(0); cin.tie(0); #define ll long long using namespace std; void work(); int main() { ___ int t = 1; cin >> t; while (t--) work(); } void work() { multiset<ll> dq; int n; cin>>n; char op; ll num; while(n--) { cin>>op>>num; if(op == 'I') { dq.insert(num); continue; } if(dq.empty()) continue; if(num == 1) dq.erase(--dq.end()); else dq.erase(dq.begin()); } if(dq.empty()) cout<<"EMPTY"<<endl; else cout<<*(--dq.end())<<' '<<*dq.begin()<<endl; } | cs |
로하이 알라딘 통계분석 정보 공유 사요나라오대영