题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2648
思路:map映射,记录一下memory的位置即可。

1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<map> 6 #include<string> 7 using namespace std; 8 int Point[10010]; 9 10 int main() { 11 int n,m,pos,price; 12 while(~scanf("%d",&n)) { 13 memset(Point,0,sizeof(Point)); 14 map<string,int>mp; 15 string str; 16 for(int i=0; i<n; i++) { 17 cin>>str; 18 if(str=="memory")pos=i; 19 mp[str]=i; 20 } 21 scanf("%d",&m); 22 while(m--) { 23 for(int k=1; k<=n; k++) { 24 scanf("%d",&price); 25 cin>>str; 26 Point[mp[str]]+=price; 27 } 28 int Rank=1; 29 for(int i=0; i<n; i++)if(Point[i]>Point[pos])Rank++; 30 printf("%d\n",Rank); 31 } 32 } 33 return 0; 34 }