10525 | 2024-04-04 16:18:01 | 111 | Jobstown-i milliomos | cpp17 | Accepted 100/100 | 1.835s | 7720 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
vector<int>v(N),p(501),dp(250501);
for(int i=0;i<N;i++){
cin>>v[i];
}
for(int i=0;i<N;i++){
int x;
cin>>x;
p[v[i]]=max(p[v[i]],x);
}
for(int i=1;i<=500;i++){
p[i]=max(p[i],p[i-1]);
}
for(int i=0;i<250000;i++){
for(int j=1;j<=500;j++){
dp[i+j]=max(dp[i+j],dp[i]+p[j]);
}
}
int ans=0;
for(int i=0;i<=min(M,250000ll);i++){
for(int j=1;j<=500;j++){
ans=max(ans,dp[i]+(M-i)/j*p[j]);
}
}
cout<<ans<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 187ms | 5916 KiB | ||||
2 | Accepted | 186ms | 6208 KiB | ||||
subtask2 | 25/25 | ||||||
3 | Accepted | 186ms | 6244 KiB | ||||
4 | Accepted | 186ms | 6460 KiB | ||||
5 | Accepted | 515ms | 6496 KiB | ||||
6 | Accepted | 515ms | 6636 KiB | ||||
7 | Accepted | 515ms | 6572 KiB | ||||
8 | Accepted | 515ms | 6576 KiB | ||||
9 | Accepted | 515ms | 6604 KiB | ||||
10 | Accepted | 515ms | 6604 KiB | ||||
11 | Accepted | 517ms | 6860 KiB | ||||
12 | Accepted | 517ms | 7028 KiB | ||||
13 | Accepted | 515ms | 6996 KiB | ||||
14 | Accepted | 515ms | 6996 KiB | ||||
subtask3 | 16/16 | ||||||
15 | Accepted | 1.835s | 7144 KiB | ||||
16 | Accepted | 1.835s | 7172 KiB | ||||
17 | Accepted | 1.835s | 7128 KiB | ||||
18 | Accepted | 1.835s | 7416 KiB | ||||
19 | Accepted | 1.835s | 7424 KiB | ||||
20 | Accepted | 1.835s | 7340 KiB | ||||
21 | Accepted | 1.835s | 7336 KiB | ||||
subtask4 | 59/59 | ||||||
22 | Accepted | 186ms | 7376 KiB | ||||
23 | Accepted | 186ms | 7380 KiB | ||||
24 | Accepted | 1.835s | 7384 KiB | ||||
25 | Accepted | 1.835s | 7372 KiB | ||||
26 | Accepted | 1.835s | 7340 KiB | ||||
27 | Accepted | 1.835s | 7460 KiB | ||||
28 | Accepted | 1.835s | 7496 KiB | ||||
29 | Accepted | 1.835s | 7496 KiB | ||||
30 | Accepted | 1.835s | 7340 KiB | ||||
31 | Accepted | 1.835s | 7488 KiB | ||||
32 | Accepted | 1.835s | 7476 KiB | ||||
33 | Accepted | 1.835s | 7720 KiB |