Start: Dec, 04, 2016 12:00:00
杭州师范大学第十届程序设计竞赛—正式
End: Dec, 04, 2016 17:00:00
Time elapsed:
Time remaining:

Problem_ID: B
Result: Accepted
Time: 1ms
Memory: 1092kB
In contest: 1075

#include<stdio.h>
void bubblesort(float time[],int m);
int main(){
	int t,m,sum,i;
	float n,time[100],total;
	scanf("%d",&t);
	while(t--){
		scanf("%f%d",&n,&m);
		for(i=0;i<m;++i){
			scanf("%f",&time[i]);
		}
		bubblesort(time,m);
		total=0;
		sum=0;
		for(i=0;i<m;++i){
			total+=time[i];
			if(total > n)
				break;
			else
				sum+=1;
		}
		printf("%d\n",sum);
	}
	return 0;
}void bubblesort(float time[],int m){
	int i,j,temp;
	for(i=1;i<m;++i){
		for(j=0;j<m-i;++j){
			if(time[j]>time[j+1]){
				temp=time[j];
				time[j]=time[j+1];
				time[j+1]=temp;
			}
		}
	}
}