10545 | 2024-04-04 20:25:38 | 111 | Az IKPC legerősebb csapata | cpp17 | Wrong answer 0/100 | 448ms | 1046868 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]);
}
for(int k=j-1;k>=0&&a[k]<a[j];k--){
dp1[i][j]=max(dp1[i][j],dp1[i][k]+b[j]);
if(k>=2&&a[k-1]<a[k]){
break;
}
}
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 | 1976 KiB | ||||
2 | Accepted | 3ms | 2196 KiB | ||||
subtask2 | 0/9 | ||||||
3 | Accepted | 2ms | 2208 KiB | ||||
4 | Wrong answer | 2ms | 2132 KiB | ||||
5 | Wrong answer | 3ms | 2260 KiB | ||||
6 | Accepted | 2ms | 2296 KiB | ||||
7 | Accepted | 3ms | 2424 KiB | ||||
8 | Wrong answer | 3ms | 2664 KiB | ||||
9 | Wrong answer | 3ms | 2892 KiB | ||||
10 | Accepted | 2ms | 2972 KiB | ||||
11 | Wrong answer | 3ms | 3104 KiB | ||||
12 | Wrong answer | 3ms | 3324 KiB | ||||
subtask3 | 0/7 | ||||||
13 | Accepted | 10ms | 19460 KiB | ||||
14 | Wrong answer | 10ms | 17576 KiB | ||||
15 | Wrong answer | 32ms | 54376 KiB | ||||
16 | Accepted | 128ms | 216876 KiB | ||||
17 | Accepted | 172ms | 292776 KiB | ||||
18 | Accepted | 86ms | 146588 KiB | ||||
19 | Accepted | 86ms | 146872 KiB | ||||
20 | Wrong answer | 9ms | 15468 KiB | ||||
21 | Accepted | 305ms | 506648 KiB | ||||
subtask4 | 0/11 | ||||||
22 | Runtime error | 358ms | 1046868 KiB | ||||
23 | Runtime error | 360ms | 1046856 KiB | ||||
24 | Runtime error | 358ms | 1046832 KiB | ||||
25 | Runtime error | 442ms | 1046596 KiB | ||||
26 | Runtime error | 360ms | 1046572 KiB | ||||
27 | Runtime error | 363ms | 1046568 KiB | ||||
subtask5 | 0/22 | ||||||
28 | Wrong answer | 54ms | 91264 KiB | ||||
29 | Accepted | 97ms | 142480 KiB | ||||
30 | Accepted | 89ms | 147272 KiB | ||||
31 | Wrong answer | 158ms | 259920 KiB | ||||
32 | Wrong answer | 28ms | 48300 KiB | ||||
33 | Wrong answer | 134ms | 228708 KiB | ||||
34 | Wrong answer | 13ms | 21388 KiB | ||||
subtask6 | 0/51 | ||||||
35 | Runtime error | 363ms | 1046380 KiB | ||||
36 | Runtime error | 365ms | 1046356 KiB | ||||
37 | Runtime error | 448ms | 1046124 KiB | ||||
38 | Runtime error | 365ms | 1046124 KiB | ||||
39 | Runtime error | 365ms | 1046116 KiB | ||||
40 | Runtime error | 361ms | 1046116 KiB | ||||
41 | Runtime error | 365ms | 1046120 KiB | ||||
42 | Runtime error | 363ms | 1046076 KiB | ||||
43 | Runtime error | 363ms | 1046076 KiB | ||||
44 | Runtime error | 361ms | 1046100 KiB | ||||
45 | Runtime error | 363ms | 1046104 KiB |