#include<bits/stdc++.h>
using namespace std;
int main(){
int m,n,p;
while(cin>>n){
string s;
map <string,int> shop;
for(int i=0;i<n;++i) cin>>s;
cin>>m;
while(m--){
for(int j=0;j<n;j++){
cin>>p>>s;
shop[s]+=p;
}
int rank=1;
map <string,int> ::iterator it;
for(it=shop.begin();it!=shop.end();++it){
if(it->second>shop["memory"]) rank++;
}
cout<<rank<<endl;
}
shop.clear();
}
return 0;
}
- map <string,int> ::iterator it;
- 迭代器的使用
- for(int j=0;j<n;j++){
cin>>p>>s;
shop[s]+=p;
}
map数据的录入
4.if(it->second it迭代器的指针作用