10543 | 2024-04-04 20:20:33 | 111 | Az IKPC legerősebb csapata | cpp17 | Wrong answer 0/100 | 448ms | 1046852 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]);
dp1[i][j]=max(dp1[i][j],dp1[i][j-1]-b[j-1]+b[j]);
}
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 | Wrong answer | 3ms | 1832 KiB | ||||
2 | Accepted | 3ms | 2048 KiB | ||||
subtask2 | 0/9 | ||||||
3 | Accepted | 3ms | 2292 KiB | ||||
4 | Wrong answer | 3ms | 2368 KiB | ||||
5 | Wrong answer | 3ms | 2568 KiB | ||||
6 | Accepted | 3ms | 2772 KiB | ||||
7 | Accepted | 3ms | 2904 KiB | ||||
8 | Wrong answer | 3ms | 3036 KiB | ||||
9 | Wrong answer | 3ms | 3076 KiB | ||||
10 | Wrong answer | 3ms | 3184 KiB | ||||
11 | Wrong answer | 2ms | 3184 KiB | ||||
12 | Wrong answer | 2ms | 3176 KiB | ||||
subtask3 | 0/7 | ||||||
13 | Accepted | 10ms | 19328 KiB | ||||
14 | Wrong answer | 10ms | 17448 KiB | ||||
15 | Wrong answer | 32ms | 54428 KiB | ||||
16 | Accepted | 127ms | 216888 KiB | ||||
17 | Accepted | 170ms | 292716 KiB | ||||
18 | Wrong answer | 86ms | 146504 KiB | ||||
19 | Wrong answer | 86ms | 146504 KiB | ||||
20 | Wrong answer | 9ms | 15332 KiB | ||||
21 | Accepted | 301ms | 506768 KiB | ||||
subtask4 | 0/11 | ||||||
22 | Runtime error | 363ms | 1046852 KiB | ||||
23 | Runtime error | 439ms | 1046660 KiB | ||||
24 | Runtime error | 365ms | 1046620 KiB | ||||
25 | Runtime error | 361ms | 1046604 KiB | ||||
26 | Runtime error | 358ms | 1046600 KiB | ||||
27 | Runtime error | 361ms | 1046532 KiB | ||||
subtask5 | 0/22 | ||||||
28 | Wrong answer | 61ms | 91276 KiB | ||||
29 | Accepted | 97ms | 142356 KiB | ||||
30 | Accepted | 101ms | 147280 KiB | ||||
31 | Wrong answer | 180ms | 259916 KiB | ||||
32 | Wrong answer | 32ms | 48672 KiB | ||||
33 | Wrong answer | 156ms | 229024 KiB | ||||
34 | Wrong answer | 13ms | 21720 KiB | ||||
subtask6 | 0/51 | ||||||
35 | Runtime error | 360ms | 1045940 KiB | ||||
36 | Runtime error | 448ms | 1045932 KiB | ||||
37 | Runtime error | 363ms | 1045912 KiB | ||||
38 | Runtime error | 361ms | 1045892 KiB | ||||
39 | Runtime error | 363ms | 1045856 KiB | ||||
40 | Runtime error | 368ms | 1045880 KiB | ||||
41 | Runtime error | 365ms | 1045844 KiB | ||||
42 | Runtime error | 361ms | 1045864 KiB | ||||
43 | Runtime error | 363ms | 1045852 KiB | ||||
44 | Runtime error | 361ms | 1045852 KiB | ||||
45 | Runtime error | 412ms | 1045860 KiB |