Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. struct score {
  7.     int points;
  8.     int time;
  9. };
  10.  
  11. class srt {
  12. public:
  13.     bool operator()(const score &a, const score &b) {
  14.         if (a.points == b.points)
  15.             return a.time > b.time;
  16.         else
  17.             return a.points > b.points;
  18.     }
  19. };
  20.  
  21. int main() {
  22.     int m, n;
  23.     cin >> m >> n;
  24.     map<string, string, srt> table;
  25.     for (size_t i = 0; i < n; i++) {
  26.         string s;
  27.         score x{};
  28.         if (table[s].points < x.points) {
  29.             x.time = i;
  30.             table[s] = x;
  31.         }
  32.     }
  33.     for (auto item : table) {
  34.         cout << item.first << "\n";
  35.     }
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement