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 |
ymIn Reply To:标准答案。。。 Posted by:drownever at 2006-12-23 09:03:41 > #include<iostream.h> > int main() > { > int t; > cin>>t; > int tt=0; > while(t--) > { > int array[1001],temp=0,people; > long a; > cin>>a>>people; > while(people--) > { > cin>>array[temp++]; > } > for(int i=0;i<temp;i++) > for(int j=i;j<temp;j++) > { > if(array[i]<array[j]) > { > int ss=array[j]; > array[j]=array[i]; > array[i]=ss; > } > } > > int result=1; > long sum=0; > people=temp; > temp=0; > while(1) > { > if(result>people) > { > cout<<"Scenario #"<<++tt<<":"<<endl<<"impossible"<<endl<<endl; > break; > } > sum=sum+array[temp++]; > > if(sum>=a) > { > cout<<"Scenario #"<<++tt<<":"<<endl<<result<<endl<<endl; > break; > } > result++; > } > > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator