Submission

Status:

[P-SSSSSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: Shangbin

Problemset: laracroft

Language: cpp

Time: 0.003 second

Submitted On: 2026-01-11 21:51:19

//Problem = https://grader.gchan.moe/problemset/c2_knb64_laracroft
#include <bits/stdc++.h>
using namespace std;

const int maxn = 505, maxW = 2005, inf = 1e9;
int n, wlimit, g[maxn], w[maxn], dp[maxn][maxW];

int main(){
    cin >> n >> wlimit;
    for (int i = 1; i <= n; i++) cin >> g[i];
    for (int i = 1; i <= n; i++) cin >> w[i];
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= wlimit; j++){
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j >= w[i]) 
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + g[i]);
        }
    }
    int ans1 = dp[n][wlimit];
    for (int i = 0; i < maxW; i++){
        if (dp[n][i] == ans1){
            cout << ans1 << ' ' << dp[n][i];
            return 0;
        }
    }
}