p1048为什么全WA
查看原帖
p1048为什么全WA
1135072
uwutongshu楼主2024/6/15 16:07
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
long long f[1100][1100]={0};
int main ()
{
	int t,m;
	cin>>t>>m;
	for(int i=0;i<m;i++)
	cin>>a[i]>>b[i];
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=t;j++)
		{
			f[i][j]=max(f[i-1][j],f[i-1][j-a[i-1]]+b[i-1]);
		}
	}
	cout<<f[m-1][t-1];
	return 0;
}
2024/6/15 16:07
加载中...