#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<string> operations) {
vector<int> answer;
vector<int> v;
for (int i = 0; i < operations.size(); i++) {
if (operations[i][0] == 'D') {
sort(v.begin(), v.end());
if (v.size() == 0)
continue;
else {
if (operations[i][2] == '1')
v.erase(v.begin() + v.size() - 1);
else
v.erase(v.begin());
}
}
else {
v.push_back(stoi(operations[i].substr(2)));
}
}
if (v.size() == 0) {
answer.push_back(0);
answer.push_back(0);
}
else {
sort(v.begin(), v.end());
answer.push_back(v[v.size() - 1]);
answer.push_back(v[0]);
}
return answer;
}
프로그래머스