Start: Dec, 04, 2016 12:00:00
杭州师范大学第十届程序设计竞赛—正式
End: Dec, 04, 2016 17:00:00
Time elapsed:
Time remaining:

Problem_ID: B
Result: Accepted
Time: 2ms
Memory: 1704kB
In contest: 1075

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int a[105];
		int n,m,ans=0;
		cin>>n>>m;
		for(int i=0;i<m;i++)
		{
			cin>>a[i];
		}
		sort(a,a+m);
		for(int i=0;i<m;i++)
		{
			if(n>=a[i])
			{
				ans++;
				n-=a[i];
			}
		}
		cout<<ans<<endl;
	}
}