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,b,c,d,e[105],f,h;
	scanf("%d",&a);
	while(a--)
	{
		scanf("%d%d",&b,&c);
		for(d=0;d<c;d++)
		{
			scanf("%d",&e[d]);
		}
		for(d=0;d<c-1;d++)
		{
			for(f=d+1;f<c;f++)
			{
				if(e[d]>e[f])
				{
					h=e[d];
					e[d]=e[f];
					e[f]=h;
				}
			}
		}
		for(d=0;b>=0&&d<=c;d++)
		{
			b-=e[d];
		}
		printf("%d\n",d-1);
	}


}