Notice
Recent Posts
Recent Comments
250x250
Creative Code
[7662번]이중 우선순위 큐 본문
728x90
https://www.acmicpc.net/problem/7662
#include <iostream>
#include <set>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t, k, n;
char c;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> k;
multiset<int> m;
for (int j = 0; j < k; j++) {
cin >> c >> n;
if (c == 'I') {
m.insert(n);
}
else {
if (!m.empty() && n == -1) {
m.erase(m.begin());
}
else if (!m.empty() && n == 1) {
auto iter = m.end();
iter--;
m.erase(iter);
}
}
}
if (m.empty()) {
cout << "EMPTY" << "\n";
}
else {
auto it = m.end();
it--;
cout << *it << " " << *m.begin() << "\n";
}
}
return 0;
}
728x90
'백준 문제풀이' 카테고리의 다른 글
[9663번]N-Queen (0) | 2023.09.24 |
---|---|
[9019번]DSLR (0) | 2023.09.24 |
[1806번]부분합 (0) | 2023.09.24 |
[1753번]최단경로 (0) | 2023.09.24 |
[1043번]거짓말 (0) | 2023.09.24 |