10542 | 2024-04-04 20:16:43 | 111 | Az IKPC legerősebb csapata | cpp17 | Wrong answer 0/100 | 446ms | 1046884 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]);
}
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 | 2024 KiB | ||||
subtask2 | 0/9 | ||||||
3 | Accepted | 3ms | 2236 KiB | ||||
4 | Wrong answer | 3ms | 2340 KiB | ||||
5 | Wrong answer | 3ms | 2568 KiB | ||||
6 | Accepted | 3ms | 2768 KiB | ||||
7 | Accepted | 3ms | 2984 KiB | ||||
8 | Wrong answer | 3ms | 3204 KiB | ||||
9 | Wrong answer | 3ms | 3432 KiB | ||||
10 | Accepted | 2ms | 3504 KiB | ||||
11 | Wrong answer | 3ms | 3632 KiB | ||||
12 | Wrong answer | 2ms | 3712 KiB | ||||
subtask3 | 0/7 | ||||||
13 | Accepted | 10ms | 19956 KiB | ||||
14 | Wrong answer | 9ms | 17880 KiB | ||||
15 | Wrong answer | 29ms | 54632 KiB | ||||
16 | Accepted | 116ms | 217088 KiB | ||||
17 | Accepted | 156ms | 292972 KiB | ||||
18 | Wrong answer | 79ms | 146692 KiB | ||||
19 | Wrong answer | 79ms | 146696 KiB | ||||
20 | Wrong answer | 9ms | 15524 KiB | ||||
21 | Accepted | 273ms | 506568 KiB | ||||
subtask4 | 0/11 | ||||||
22 | Runtime error | 356ms | 1046884 KiB | ||||
23 | Runtime error | 354ms | 1046864 KiB | ||||
24 | Runtime error | 360ms | 1046836 KiB | ||||
25 | Runtime error | 358ms | 1046832 KiB | ||||
26 | Runtime error | 356ms | 1046708 KiB | ||||
27 | Runtime error | 352ms | 1046712 KiB | ||||
subtask5 | 0/22 | ||||||
28 | Wrong answer | 50ms | 91124 KiB | ||||
29 | Accepted | 76ms | 142200 KiB | ||||
30 | Accepted | 79ms | 146868 KiB | ||||
31 | Wrong answer | 143ms | 259388 KiB | ||||
32 | Wrong answer | 27ms | 47904 KiB | ||||
33 | Wrong answer | 123ms | 228216 KiB | ||||
34 | Wrong answer | 13ms | 21072 KiB | ||||
subtask6 | 0/51 | ||||||
35 | Runtime error | 356ms | 1046724 KiB | ||||
36 | Runtime error | 354ms | 1046728 KiB | ||||
37 | Runtime error | 358ms | 1046704 KiB | ||||
38 | Runtime error | 354ms | 1046696 KiB | ||||
39 | Runtime error | 356ms | 1046684 KiB | ||||
40 | Runtime error | 360ms | 1046664 KiB | ||||
41 | Runtime error | 358ms | 1046676 KiB | ||||
42 | Runtime error | 358ms | 1046668 KiB | ||||
43 | Runtime error | 446ms | 1046440 KiB | ||||
44 | Runtime error | 356ms | 1046444 KiB | ||||
45 | Runtime error | 358ms | 1046440 KiB |