N<=100 数组开到10的6次方还RE这对吗
查看原帖
N<=100 数组开到10的6次方还RE这对吗
1088101
111122a楼主2025/1/21 21:03
#include<bits/stdc++.h>
using namespace std;
int M,T,n,dp[10000010];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>M;
	for(int i=1;i<=n;i++){
		int m,p;
		cin>>m>>p;
		for(int j=M;j>=m;j--){
			dp[j]=max(dp[j],dp[j-m]+p);
		}
	}
	cout<<dp[M]<<'\n';
	return 0;
}
2025/1/21 21:03
加载中...