96792024-02-24 17:35:25szilJobstown-i milliomoscpp17Accepted 100/100259ms10596 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted8ms7528 KiB
2Accepted7ms7744 KiB
subtask225/25
3Accepted7ms7952 KiB
4Accepted7ms8160 KiB
5Accepted179ms8248 KiB
6Accepted178ms8132 KiB
7Accepted178ms8352 KiB
8Accepted178ms8472 KiB
9Accepted179ms8820 KiB
10Accepted179ms8892 KiB
11Accepted252ms8864 KiB
12Accepted246ms9068 KiB
13Accepted256ms9232 KiB
14Accepted6ms9320 KiB
subtask316/16
15Accepted259ms9412 KiB
16Accepted248ms9480 KiB
17Accepted248ms9744 KiB
18Accepted6ms9692 KiB
19Accepted194ms9692 KiB
20Accepted194ms9848 KiB
21Accepted194ms9828 KiB
subtask459/59
22Accepted7ms9972 KiB
23Accepted7ms9936 KiB
24Accepted178ms9944 KiB
25Accepted178ms10020 KiB
26Accepted178ms10108 KiB
27Accepted257ms9964 KiB
28Accepted250ms10180 KiB
29Accepted247ms10264 KiB
30Accepted6ms10344 KiB
31Accepted179ms10344 KiB
32Accepted178ms10476 KiB
33Accepted178ms10596 KiB