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 |
Re:RunError Why?In Reply To:RunError Why? Posted by:alzhu at 2008-12-15 19:07:02 > #include <stdio.h> > #include <iostream> > #include <string> > #include <cmath> > #include <algorithm> > using namespace std; > > > int main() > { > int a,b,d,e,f,k,impossible; > scanf("%d",&a); > for(int i=1;a--;i++) > { > scanf("%d%d",&b,&f); > int *c=new int[b]; > for(int j=0;j<f;j++) > { > scanf("%d",&c[j]); > } > sort(&c[0],&c[f]); > d=0; > impossible=0; > for(k=f-1,e=0;d<b;k--,e++) > { > if(k<0) > { > impossible=1; > break;//这里要退出循环! > } > d+=c[k]; > } > printf("Scenario #%d:\n",i); > if(!impossible) > printf("%d\n\n",e); > else > printf("impossible\n\n"); > delete [] c; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator