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>
int main(){
int a;
int b,c,d;
int q;
int t=0;
int count=0;
int m[100];
int i,temp;
int zong=0,k;
scanf("%d",&a);
while(a--){
	count=0;t=0;
	scanf("%d%d",&b,&c);
	for(d=0;d<c ;d++){
	scanf("%d",&m[d]);
	}
	for(i=1;i<c;i++){
		temp=0;
		for(t=0;t<c-i;t++){
			if(m[t]>m[t+1]){
			temp=m[t];
			m[t]=m[t+1];
			m[t+1]=temp;
			}
		}
	}
	zong=0;
	for(k=0;k<c;k++){
	if(m[k]<=b){
	zong=zong+m[k];
	if(zong<=b) count++; 
	}
	}
	printf("%d\n",count);
}
	
}