9679 | 2024-02-24 17:35:25 | szil | Jobstown-i milliomos | cpp17 | Accepted 100/100 | 259ms | 10596 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX(a, b) a = max(a, b)
const int MAXN = 501;
const int MAXV = 600*600;
ll dp[MAXV];
ll t[MAXN], p[MAXN];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin>>n>>m;
for (int i = 1; i <= n; i++) cin >> t[i];
for (int i = 1; i <= n; i++) cin >> p[i];
for(int i = 1; i <= n; i++){
for(int j = 0; j+t[i] < MAXV; j++){
MAX(dp[j+t[i]], dp[j] + p[i]);
}
}
ll mx = 0;
for (int i = 1; i <= n; i++) {
ll cnt = (m-MAXV >= 0) ? ((m-MAXV+t[i])/t[i]) : 0;
ll next_m = m - cnt*t[i];
ll curr = p[i]*cnt + dp[next_m];
MAX(mx, curr);
}
cout<<mx<<endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 8ms | 7528 KiB | ||||
2 | Accepted | 7ms | 7744 KiB | ||||
subtask2 | 25/25 | ||||||
3 | Accepted | 7ms | 7952 KiB | ||||
4 | Accepted | 7ms | 8160 KiB | ||||
5 | Accepted | 179ms | 8248 KiB | ||||
6 | Accepted | 178ms | 8132 KiB | ||||
7 | Accepted | 178ms | 8352 KiB | ||||
8 | Accepted | 178ms | 8472 KiB | ||||
9 | Accepted | 179ms | 8820 KiB | ||||
10 | Accepted | 179ms | 8892 KiB | ||||
11 | Accepted | 252ms | 8864 KiB | ||||
12 | Accepted | 246ms | 9068 KiB | ||||
13 | Accepted | 256ms | 9232 KiB | ||||
14 | Accepted | 6ms | 9320 KiB | ||||
subtask3 | 16/16 | ||||||
15 | Accepted | 259ms | 9412 KiB | ||||
16 | Accepted | 248ms | 9480 KiB | ||||
17 | Accepted | 248ms | 9744 KiB | ||||
18 | Accepted | 6ms | 9692 KiB | ||||
19 | Accepted | 194ms | 9692 KiB | ||||
20 | Accepted | 194ms | 9848 KiB | ||||
21 | Accepted | 194ms | 9828 KiB | ||||
subtask4 | 59/59 | ||||||
22 | Accepted | 7ms | 9972 KiB | ||||
23 | Accepted | 7ms | 9936 KiB | ||||
24 | Accepted | 178ms | 9944 KiB | ||||
25 | Accepted | 178ms | 10020 KiB | ||||
26 | Accepted | 178ms | 10108 KiB | ||||
27 | Accepted | 257ms | 9964 KiB | ||||
28 | Accepted | 250ms | 10180 KiB | ||||
29 | Accepted | 247ms | 10264 KiB | ||||
30 | Accepted | 6ms | 10344 KiB | ||||
31 | Accepted | 179ms | 10344 KiB | ||||
32 | Accepted | 178ms | 10476 KiB | ||||
33 | Accepted | 178ms | 10596 KiB |