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 |
今天我晚了差不多一个小时才开始做,时间好亏In Reply To:这就像咱们比赛,先在简单的,肯定是最优,但是不知为什么,只做出steve的WA, 三个人都写的话就AC,帮我看看 Posted by:sunmoonstar_love at 2005-07-20 19:40:30 > #include <stdio.h> > #include <stdlib.h> > #include <iostream> > using namespace std; > int cmp1(int* a, int* b) > { > if(*a<*b) > return 1; > return 0; > } > int cmp2(int* a, int* b) > { > if(*a>*b) > return 1; > return 0; > } > > int bill[25],steve[25],linus[25],s1,s2,s3,i,j,k,test,sce,minute,problem,score1,score2,score3; > int main() > { > scanf("%d",&test); > for(sce=1; sce<=test; sce++) > { > scanf("%d%d",&minute,&problem); > for(i=0; i<problem; i++) > { > scanf("%d",&bill[i]); > steve[i] = linus[i] = bill[i]; > } > qsort(steve,problem,sizeof(int),(int(*)(const void*, const void*))cmp2); > for(i=1; i<problem; i++) > { > steve[i] += steve[i-1]; > linus[i] += linus[i-1]; > bill[i] += bill[i-1]; > } > s1 = s2 = s3 = score1 = score2 = score3 = 0; > for(i=0; i<problem; i++) > { > if(steve[i]<=minute) > { > score2 += steve[i]; > s2++; > } > else > break; > } > printf("Scenario #%d:\nSteve wins with %d solved problems and a score of %d.\n\n",sce,s2,score2); > > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator