update
This commit is contained in:
parent
4c81e798a2
commit
17a7d83060
29
day13/P1507/P1507.cpp
Normal file
29
day13/P1507/P1507.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user