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 |
牛人们;帮我查一下错误(附源码)这么简单的题你们看一眼就OK!!!In Reply To:这两天,硬币做多了,什么都做成coin,结果tle n次ft~~~~~~~ Posted by:sunmoonstar_love at 2005-07-17 15:16:04 #include<stdio.h> int main() { int i,j,t; int n,m,p=0; int a[1000],b[1000]; long k,sum; scanf("%d",&n); while(p<n) { sum=0; scanf("%ld%d",&k,&m); for(i=0;i<m;i++) scanf("%d",&a[i]); for(i=0;i<m-1;i++) { for(j=m-1;j>=i;j--) { if(a[j]<a[j+1]) { t=a[j+1];a[j+1]=a[j];a[j]=t; } } sum+=a[i]; if(sum<k) b[p]=i+2; } if(sum<k) b[p]=0; p++; } for(i=0;i<n;i++) { printf("Scenario #%d:\n",i+1); if(b[i]==0) printf("impossible\n"); if(b[i]!=0) printf("%d\n",b[i]); printf("\n"); } return 1; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator