#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 10005
map<string,int> elem;
int node[N];
int main()

{
    int n,m,i,val,j,rank;
    string str;
    while(cin>>n){
        int n1=n;
        for(i=1;i<=n1;i++){
            cin>>str;
            if(str=="memory")
            {
                str[0]='0';
                elem[str]=0;
                i--;
                n1--;
            }
            else
                elem[str]=i;
        }
        memset(node,0,sizeof(node));
        scanf("%d",&m);
        while(m--){
            for(i=1;i<=n;i++)
            {
                cin>>val>>str;
                if(str=="memory")
                    str[0]='0';
                node[elem[str]]+=val;
            }
            int cnt=0;
            for(i=1;i<n;i++){
                if(node[i]>node[0])
                    cnt++;
            }
            printf("%d\n",cnt+1);
        }
    }
    return 0;
}

相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2021-07-13
猜你喜欢
  • 2021-11-30
  • 2021-06-10
  • 2021-09-16
  • 2021-11-17
  • 2021-06-29
  • 2021-10-20
  • 2021-12-05
相关资源
相似解决方案