This commit is contained in:
Zengtudor 2024-08-16 20:33:33 +08:00
parent 4c81e798a2
commit 17a7d83060
2 changed files with 34 additions and 1 deletions

29
day13/P1507/P1507.cpp Normal file
View File

@ -0,0 +1,29 @@
//AC
#include <algorithm>
#include <ios>
#include <iostream>
using namespace std;
#define int long long
const int MAX=400+5;
int H,T,n;
int dp[MAX][MAX],h[MAX],t[MAX],k[MAX];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>H>>T;
cin>>n;
for(int i=1;i<=n;i++){
cin>>h[i]>>t[i]>>k[i];
}
for(int i=1;i<=n;i++){
for(int j=H;j>=h[i];j--){//体积
for(int q=T;q>=t[i];q--){//质量
dp[j][q]=max(dp[j][q],dp[j-h[i]][q-t[i]]+k[i]);
}
}
}
cout<<dp[H][T]<<endl;
}

View File

@ -166,3 +166,7 @@ target("P1855")
target("P1049")
set_rundir("day13/P1049")
add_files("day13/P1049/P1049.cpp")
target("P1507")
set_rundir("day13/P1507")
add_files("day13/P1507/P1507.cpp")