Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why RE??#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct stu { int s; char n[31]; }a[10001],*b[10001]; bool cmp1(struct stu x,struct stu y) { if(strcmp(x.n,y.n)>0)return false; return true; } bool cmp2(struct stu *x,struct stu *y) { if((*x).s<(*y).s)return false; if((*x).s==(*y).s&&strcmp((*y).n,"Li Ming")==0)return false; return true; } int main() { int n; scanf("%d",&n); gets(a[0].n); for(int i=1;i<=n;i++)gets(a[i].n),a[i].s=0,b[i]=a+i; sort(a+1,a+n+1,cmp1); int m; scanf("%d",&m); for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { int s; scanf("%d",&s); char p[100],*q=p; gets(p); while(*q==' ')q++; int f=1,t=n; while(f<t) { int m=(f+t)/2,z=strcmp(q,a[m].n); if(z==0)f=t=m; else { if(z>0)f=m+1; else t=m-1; } } a[f].s+=s; } sort(b+1,b+n+1,cmp2); int j=1; while(strcmp((*b[j]).n,"Li Ming"))j++; printf("%d\n",j); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator