| ||||||||||
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 |
poj 1323不知道哪里有错,WA到快失去信心了 #include<stdio.h> #include<stdlib.h> #include<string.h> int cmp(const void *a,const void *b) { return(*(int *)b-*(int *)a); } int main() { int inpt[10000],flag[10000]; int other[10000]; int peo,ncard,i,count=0; while(scanf("%d %d",&peo,&ncard)!=EOF) { if(peo==0 && ncard==0) break; memset(flag,0,sizeof(flag)); memset(other,0,sizeof(other)); memset(inpt,0,sizeof(inpt)); int maxpip; maxpip=peo*ncard; for(i=0;i<ncard;i++) { scanf("%d",&inpt[i]); flag[inpt[i]]=1; } for(i=1;i<=maxpip;i++) { if(flag[i]==0) { other[i]=i; } } qsort(inpt,ncard,sizeof(inpt[0]),cmp); qsort(other,maxpip,sizeof(other[0]),cmp); int k=0,j=0,gain=0; while(k!=ncard) { if(inpt[k]>other[j]) { gain++; k++; } else { k++; j++; } } printf("Case %d: %d\n",++count,gain); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator