Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- class Location {
- public:
- string name;
- int score;
- Location(string _name, int _score): name(_name), score(_score) {}
- bool operator<(const Location& rhs) const {
- if (score != rhs.score)
- return score > rhs.score;
- return name < rhs.name;
- }
- };
- #define ordered_set tree<Location, null_type, less<Location>, rb_tree_tag, tree_order_statistics_node_update>
- class SORTracker {
- public:
- ordered_set arr;
- int queryIndex = 0;
- SORTracker() {
- }
- void add(string name, int score) {
- arr.insert(Location(name, score));
- }
- string get() {
- return arr.find_by_order(queryIndex++)->name;
- }
- };
- /**
- * Your SORTracker object will be instantiated and called as such:
- * SORTracker* obj = new SORTracker();
- * obj->add(name,score);
- * string param_2 = obj->get();
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement