10544 | 2024-04-04 20:21:35 | 111 | Az IKPC legerősebb csapata | cpp17 | Wrong answer 0/100 | 423ms | 1047084 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,K;
cin>>N>>K;
vector<int>a(N+1),b(N+1);
for(int i=1;i<=N;i++){
cin>>a[i];
}
for(int i=1;i<=N;i++){
cin>>b[i];
}
vector<vector<int>>dp0(K+1,vector<int>(N+1,0)),dp1(K+1,vector<int>(N+1,0));
for(int i=1;i<=K;i++){
for(int j=1;j<=N;j++){
dp0[i][j]=max(dp0[i][j-1],dp0[i-1][j]);
dp0[i][j]=max(dp0[i][j],dp0[i-1][j-1]+b[j]);
dp1[i][j]=max(dp1[i][j],dp0[i-1][j-1]+b[j]);
if(a[j-1]<a[j]){
dp1[i][j]=max(dp1[i][j],dp1[i][j-1]+b[j]);
}
if(a[j-1]==a[j]){
dp1[i][j]=max(dp1[i][j],dp1[i][j-1]);
}
dp0[i][j]=max(dp0[i][j],dp1[i][j]);
}
}
cout<<dp0[K][N]<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2056 KiB | ||||
subtask2 | 0/9 | ||||||
3 | Accepted | 3ms | 2288 KiB | ||||
4 | Wrong answer | 3ms | 2464 KiB | ||||
5 | Wrong answer | 3ms | 2568 KiB | ||||
6 | Accepted | 3ms | 2776 KiB | ||||
7 | Accepted | 3ms | 2988 KiB | ||||
8 | Wrong answer | 3ms | 3216 KiB | ||||
9 | Wrong answer | 2ms | 3324 KiB | ||||
10 | Accepted | 3ms | 3428 KiB | ||||
11 | Wrong answer | 3ms | 3512 KiB | ||||
12 | Wrong answer | 2ms | 3592 KiB | ||||
subtask3 | 0/7 | ||||||
13 | Accepted | 10ms | 19744 KiB | ||||
14 | Wrong answer | 9ms | 17504 KiB | ||||
15 | Wrong answer | 32ms | 54348 KiB | ||||
16 | Accepted | 123ms | 216804 KiB | ||||
17 | Accepted | 164ms | 292708 KiB | ||||
18 | Wrong answer | 82ms | 146588 KiB | ||||
19 | Wrong answer | 82ms | 146588 KiB | ||||
20 | Wrong answer | 9ms | 15560 KiB | ||||
21 | Accepted | 287ms | 506560 KiB | ||||
subtask4 | 0/11 | ||||||
22 | Runtime error | 358ms | 1047084 KiB | ||||
23 | Runtime error | 358ms | 1047052 KiB | ||||
24 | Runtime error | 361ms | 1047032 KiB | ||||
25 | Runtime error | 423ms | 1047016 KiB | ||||
26 | Runtime error | 361ms | 1047016 KiB | ||||
27 | Runtime error | 363ms | 1046988 KiB | ||||
subtask5 | 0/22 | ||||||
28 | Wrong answer | 52ms | 90824 KiB | ||||
29 | Accepted | 81ms | 142016 KiB | ||||
30 | Accepted | 83ms | 146924 KiB | ||||
31 | Wrong answer | 150ms | 259188 KiB | ||||
32 | Wrong answer | 28ms | 47736 KiB | ||||
33 | Wrong answer | 128ms | 228144 KiB | ||||
34 | Wrong answer | 13ms | 20832 KiB | ||||
subtask6 | 0/51 | ||||||
35 | Runtime error | 360ms | 1046816 KiB | ||||
36 | Runtime error | 361ms | 1046776 KiB | ||||
37 | Runtime error | 361ms | 1046784 KiB | ||||
38 | Runtime error | 361ms | 1046756 KiB | ||||
39 | Runtime error | 361ms | 1046752 KiB | ||||
40 | Runtime error | 363ms | 1046744 KiB | ||||
41 | Runtime error | 363ms | 1046736 KiB | ||||
42 | Runtime error | 358ms | 1046752 KiB | ||||
43 | Runtime error | 363ms | 1046744 KiB | ||||
44 | Runtime error | 363ms | 1046744 KiB | ||||
45 | Runtime error | 361ms | 1046744 KiB |