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<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<math.h>

using namespace std;

int main(){
	int T,n,m;
	int s[200];
	cin>>T;
	while(T--){
		cin>>n>>m;
		int sum=0;
		for(int i=0;i<m;i++)cin>>s[i];
		sort(s,s+m);
		for(int i=0;i<m;i++){
			n-=s[i];
			if(n>=0)sum++;
			else break;
		}
		cout<<sum<<endl;
	}
}