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<fstream>
#include<algorithm>
#include<string.h>
#include<string>
using namespace std;
int main(){
	int T,n,m,a[101],sum,count;
	cin>>T;
	while(T--){
		sum=0;
		count=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++){
	sum=sum+a[i];
	if(sum<=n)
		count=count+1;
	else
		break;
	}
	cout<<count<<endl;
	}
	return 0;
}