Lang:G++
Edit1234567891011121314151617#include "iostream"#include "set"#include "map"using namespace std;int n; map<int, int>s;multiset<int>ss;#define b .begin()#define rb .rbegin()#define t ->first#define z ->second#define k break;void P(int x, int y) {s[x] = y;ss.insert(y);}void Q() {cout << *(ss rb) << " " << *(ss b) << " " << s rb z<< endl;}void R(int r) {while(s.size()!=0&&s b t <=r) {auto itr = ss.find(s b z);ss.erase(itr);s.erase(s b);}}int main(){cin >> n;while (n--) {char p;cin >> p;switch (p) {case 'P':int x, y;cin >> x >> y;P(x, y);k case 'Q':Q();k;default:int r;cin >> r;R(r);k}}return 0;}