Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- string str;
- int n,i , j;
- int score;
- int mx = 0;
- string k;
- map <string , int > my_map;
- map<string , int > :: iterator it;
- scanf("%d", &n);
- for(i = 0; i<n; i++) {
- cin>> str;
- cin>> score;
- it = my_map.find(str);
- if(it == my_map.end()) {
- my_map[str] = score;
- if(score > mx) {
- mx = score;
- k = str;
- }
- }
- else{
- int l = my_map[str];
- l+= score;
- my_map[str] = l;
- if(l > mx) {
- mx = l;
- k = str;
- }
- }
- }
- /* for(it = my_map.begin(); it != my_map.end(); it++) {
- cout << it->first << " " << it->second<< endl;
- }*/
- cout << k <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement