#include<bits/stdc++.h>
using namespace std;
struct hero{
string second;
int first;
bool operator < ( const hero &x) const {
if(first == x.first) { return second < x.second; }
return first > x.first;
}
};
set<hero> s;
int main()
{
int n;
while( scanf("%d",&n) && n)
{
s.clear();
while(n--){
hero h;
cin>>h.second>>h.first;
s.insert(h);
}
for(set<hero>::iterator it=s.begin();it!=s.end();it++) cout<<(*it).second<<" "<<(*it).first<<endl;
scanf("%d",&n);
while(n--){
string cha;
cin>>cha;
int a=1,b=0;
for(set<hero>::iterator it=s.begin();it!=s.end();it++){
a++;
if((*it).second==cha){
set<hero>::iterator its = it;
for(;its!=--s.begin();its--) if( (*it).first==(*its).first ) { a--; b++; }else break;
break;
}
}
if(b!=1) cout<<a<<' '<<b<<endl;
else cout<<a<<endl;
}
}
return 0;
}
hdu5131
最新推荐文章于 2016-10-13 19:32:15 发布