Submission

Status:

[PP-SSSSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: Bune

Problemset: laracroft

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-22 21:32:52

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

int main() {
  fastio

  int n, w;
  cin >> n >> w;

  vector<int> value(n), weight(n);

  for (int i = 0; i < n; i++) {
    cin >> value[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> weight[i];
  }

  vector<int> dp(w);



  for (int i = 0; i < n; i++) {
    for (int j = w; j >= 0; j--) {
      if (j - weight[i] >= 0)
        dp[j] = max(dp[j], dp[j-weight[i]] + value[i]);
    }
  }

  int mx = 0, id = 0;
  for (int i = 0; i < w; i++) { 
    if (dp[i] > mx) {
      id = i;
      mx = dp[i];
    }
  }

  cout << mx << " " << id << "\n";

  return 0;
}