fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <set>
  7. #include <vector>
  8. using namespace std;
  9. int main()
  10. {
  11. int n;
  12. cin >> n;
  13.  
  14. map<string, int> player;
  15. string winner;
  16.  
  17. for (int i = 0; i < n; i++)
  18. {
  19. string name;
  20. int score;
  21. cin >> name >> score;
  22.  
  23. player[name] += score;
  24. }
  25.  
  26. long long maxx = 0;
  27. for (const auto& pair : player)
  28. {
  29. if (pair.second > maxx)
  30. {
  31. maxx = pair.second;
  32. winner = pair.first;
  33. }
  34. }
  35.  
  36. cout << winner ;
  37.  
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0.01s 5300KB
stdin
Standard input is empty
stdout
Standard output is empty