Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- map<string,int>mapa;
- map<string,int>::iterator it;
- int qtd,pontos,maximum=0;
- string nomePessoa;
- cin>>qtd;
- for(int i=0;i<qtd;i++){
- cin>>nomePessoa>>pontos;
- it = mapa.find(nomePessoa);
- if(it == mapa.end()){ // nao tem a pessoa ainda a registra
- mapa.insert(make_pair(nomePessoa,pontos));
- }else{
- it->second +=pontos;
- }
- }
- for (auto& x: mapa) {
- if(x.second > maximum){
- nomePessoa = x.first;
- maximum = x.second;
- }
- //cout << x.first << ": " << x.second << '\n';
- }
- cout<<nomePessoa<<'\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement