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 t,n,m,i;
	scanf("%d",&t);
	while(t--)
	{
		int p=0,time[10000];
		scanf("%d %d",&n,&m);
		for(i=0;i<m;i++)
			scanf("%d",&time[i]);
		int k;
		k=m;
		while(n>0&&k>0)
		{
			k--;
			int min=10000,f=0;
			for(int i=0;i<m;i++)
			{
				if((time[i]<min)&&(time[i]>=0))
				{
					min=time[i];
					f=i;
				}
			}
			time[f]=-1;
			n-=min;
			if(n>=0)
				p++;
		}
		printf("%d\n",p);
	}
}