Description
Submission
class SORTracker {
using pis = pair<int, string>;
set<pis>::iterator it;
set<pis> Set;
public:
SORTracker() {
Set.insert({INT_MIN, "test"});
it = Set.begin();
}
void add(string name, int score) {
Set.insert({-score, name});
if(make_pair(-score, name) < *it) it = prev(it);
}
string get() {
++it;
return it->second;
}
};
/**
* Your SORTracker object will be instantiated and called as such:
* SORTracker* obj = new SORTracker();
* obj->add(name,score);
* string param_2 = obj->get();
*/