leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2102.cpp (337B)
0 class SORTracker {
1 using type_t = tuple<int, string>;
3 set<type_t> st;
4 set<type_t>::iterator pos = end(st);
6 public:
7 void add(string name, int score) {
8 const auto it = st.insert({-score, name}).first;
9 if (pos == end(st) || *it < *pos) pos--;
10 }
12 const string &get() { return get<1>(*pos++); }
13 };