#9#10TLE(玄关)
查看原帖
#9#10TLE(玄关)
1242018
aleavf楼主2024/5/29 19:31
#include<bits/stdc++.h>
using namespace std;
long long t,m,a[10010],b[10010],dp[10000010],s=1;
int main(){
	scanf("%d%d",&t,&m);
	for(int i = 1;i <= m;++i) scanf("%d%d",&a[i],&b[i]);
	for(int i = 1;i <= m;++i)
	for(int j = 1;j <= t;++j){
	while(j>=s*a[i]){
		dp[j]=max(dp[j],dp[j-s*a[i]]+s*b[i]);
		++s;
	}
	s=1;
	}
	cout<<dp[t];
	return 0;
}
2024/5/29 19:31
加载中...