This commit is contained in:
Zengtudor 2024-08-16 12:03:12 +08:00
parent d295c1b358
commit fee4e50f03
2 changed files with 41 additions and 1 deletions

36
day13/P1833/P1833.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <algorithm>
#include <iostream>
using namespace std;
const int MAX_N=10000+5;
int sh,sm,eh,em,W,n;
int w[MAX_N],v[MAX_N],c[MAX_N];
int dp[MAX_N][MAX_N];
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
char _;
cin>>sh>>_>>sm>>eh>>_>>em>>n;
W = (eh*60+em)-(sh*60+sm);
// cout<<W<<endl;
for(int i=1;i<=n;i++){
cin>>w[i]>>v[i]>>c[i];
}
for(int i=1;i<=n;i++){
if(c[i]==0){
for(int j=w[i];j<=W;j++){
dp[i][j]=max(dp[i-1][j],dp[i][j-w[i]]+v[i]);
}
}else{
for(int j=1;j<=c[i];j++){
for(int k=1;k*w[i]<=j&&k<=c[i];k++){
dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]*k]+v[i]*k);
}
}
}
}
cout<<dp[n][W]<<endl;
}

View File

@ -153,4 +153,8 @@ target("P2871")
target("P1616")
set_rundir("day13/P1616")
add_files("day13/P1616/*.cpp")
add_files("day13/P1616/*.cpp")
target("P1833")
set_rundir("day13/P1833")
add_files("day13/P1833/*.cpp")