-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook Shop.cpp
More file actions
41 lines (34 loc) · 913 Bytes
/
Copy pathBook Shop.cpp
File metadata and controls
41 lines (34 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<iostream>
#include<random>
#include<chrono>
#include<vector>
#include<algorithm>
#define SPEED ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define oo 1000000001
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define pb push_back
#define ll long long
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int sz = 1e5 + 5;
int n, x;
int h[sz], s[sz];
int dp[sz];
signed main(){
SPEED;
cin >> n >> x;
for(register int i = 1; i <= n; ++i) cin >> h[i];
for(register int i = 1; i <= n; ++i) cin >> s[i];
for(register int i = 1; i <= n; ++i){
for(int j = x; j >= h[i]; --j){
dp[j] = max(dp[j], dp[j - h[i]] + s[i]);
}
}
cout << *max_element(dp+1, dp+x+1) << '\n';
return 0;
}