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>
#include<stdlib.h>
#include<math.h>
int themin(int num,int A[]);

void main()
{
	int t,i,time,num,j,every,A[100],k=0,x=0,count;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&time,&num);
		for(j=0;j<num;j++){
			scanf("%d",&every);
			A[j]=every;}
		count=0;
		while(1)
		{
			time-=themin(num,A);
			k++;
			if(time<0)break;
			count++;
		}
		printf("%d\n",count);
	}
}
int themin(int num,int A[]){
	int every,min=10000,j,k=100;
		for(j=0;j<num;j++){
			if(A[j]<min)
			{min=A[j];
			 k=j;
			}
		}
		A[k]=10000;
		return min;
}