Submission
Status:
[PPP-SSSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: robgornpeunpadpairoundnigumaipadnea
Problemset: laracroft
Language: cpp
Time: 0.003 second
Submitted On: 2026-03-18 11:09:33
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n,m;cin>>n>>m;
vector<int> value(n);for(int i=0;i<n;i++)cin>>value[i];
vector<int> weight(n);for(int i=0;i<n;i++)cin>>weight[i];
vector<pair<int,int>> dp(m+1,{0,0});
for(int i=0;i<n;i++){
for(int w=m;w>=weight[i];w--){
int newvalue = dp[w-weight[i]].first + value[i];
int newweight = dp[w-weight[i]].second + weight[i];
if(newvalue > dp[w].first){
dp[w] = {newvalue,newweight};
}
}
}
cout << dp[m].first << ' ' << dp[m].second;
}