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

Problem_ID: B
Result: Accepted
Time: 7ms
Memory: 1700kB
In contest: 1075

#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int dp[10001]={0};
		int time[10001];
		int va[10001];
		int tot,n;
		cin>>tot>>n;
		for(int i=0;i<n;i++)
		{
			cin>>time[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=tot;j>=time[i];j--)
			{
				dp[j]=max(dp[j],dp[j-time[i]]+1);
			}
		}
		cout<<dp[tot]<<endl;
	}
}