Result: Accepted
Time: 1ms
Memory: 1092kB
#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;
}
}
}
}