Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define MAX 200000000
- #define MAXN 101
- #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
- using namespace std;
- int a[MAXN], c[MAXN], dp[MAXN][10001];
- int main() {
- fastio;
- int n, m;
- cin >> n >> m;
- for (int i = 0; i < n; i++) cin >> a[i];
- for (int i = 0; i < n; i++) cin >> c[i];
- int ans = MAX;
- dp[0][c[0]] = a[0];
- for (int i = 1; i <= n; i++) {
- for (int j = 0; j <= 10000; j++) {
- if (j - c[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - c[i]] + a[i]);
- dp[i][j] = max(dp[i][j], dp[i - 1][j]);
- if (dp[i][j] >= m) ans = min(ans, j);
- }
- }
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement