水题,唯一需要注意的是 当主角80分,排列为100 90 90 80 80是,此时为4,理解这里就过了
#include <stdio.h>
#include <string.h>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
#define inf 0xfffff
struct e
{
int id,fs;
}s[200];
int cmp(e a,e b)
{
return a.fs>b.fs;
}
int main()
{
int jk;
while(scanf("%d",&jk)!=EOF)
{ int a,b,mark;
int num=0,rank=1;
scanf("%d%d",&a,&b);
while(a!=0&&b!=0)
{
s[num].id=a;
s[num++].fs=b;
if(a==jk) mark=b;
scanf("%d%d",&a,&b);
}
sort(s,s+num,cmp);
for(int i=0;i<num;i++)
if(mark==s[i].fs) break;
else rank++;
printf("%d\n",rank);
}
}