2 条题解
-
0
by cff_0102:
#include<bits/stdc++.h> using namespace std; const int K=55, V=1e6+5; int dp[2][V]; int main(){ ios::sync_with_stdio(0);cin.tie(0); int k, v;cin>>k>>v; for(int i=1;i<=k;i++){ int c, s;cin>>c>>s; for(int j=c;j<=v;j++)dp[1][j]=dp[0][j-c]; while(s--){ int p, e;cin>>p>>e; for(int j=v;j>=c+p;j--){ dp[1][j]=max(dp[1][j], dp[1][j-p]+e); } } for(int j=0;j<=v;j++)dp[0][j]=max(dp[0][j], dp[1][j]); } cout<<dp[0][v]; return 0; } -
0
by cff_0102:
#include<bits/stdc++.h> using namespace std; const int K=55,V=1e6+5; int dp[2][V]; int main(){ ios::sync_with_stdio(0);cin.tie(0); int k,v;cin>>k>>v; for(int i=1;i<=k;i++){ int c,s;cin>>c>>s; for(int j=c;j<=v;j++)dp[1][j]=dp[0][j-c]; while(s--){ int p,e;cin>>p>>e; for(int j=v;j>=c+p;j--){ dp[1][j]=max(dp[1][j],dp[1][j-p]+e); } } for(int j=0;j<=v;j++)dp[0][j]=max(dp[0][j],dp[1][j]); } cout<<dp[0][v]; return 0; }
- 1
信息
- ID
- 2311
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 9
- 标签
- 递交数
- 12
- 已通过
- 6
- 上传者