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

Problem_ID: B
Result: Accepted
Time: 3ms
Memory: 1092kB
In contest: 1075

#include <stdio.h>
#include <string.h>
#define max(a,b) (a)>(b)?(a):(b)
int main(){

	int n,m,t,i,dp[10001];
	int j;
	int time[101];
	scanf("%d",&t);
	while (t--){
		memset(dp,0,sizeof(dp));
		scanf("%d%d",&n,&m);
		for (i=1;i<=m;i++){
			scanf("%d",&time[i]);
		}
		for (i=1;i<=m;i++){
			for (j=n;j>=time[i];j--){
				dp[j]=max(dp[j],dp[j-time[i]]+1);

			}
		}
		printf("%d\n",dp[n]);
	}
	

	return 0;
}