10541 | 2024-04-04 20:16:09 | 111 | Az IKPC legerősebb csapata | cpp17 | Wrong answer 0/100 | 1.103s | 1045948 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]);
}
}
for(int i=0;i<=K;i++){
for(int j=0;j<=N;j++){
cout<<setw(4)<<dp1[i][j]<<' ';
}cout<<endl;
}
cout<<dp0[K][N]<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1828 KiB | ||||
2 | Wrong answer | 3ms | 2048 KiB | ||||
subtask2 | 0/9 | ||||||
3 | Wrong answer | 3ms | 2260 KiB | ||||
4 | Wrong answer | 3ms | 2464 KiB | ||||
5 | Wrong answer | 3ms | 2684 KiB | ||||
6 | Wrong answer | 3ms | 2764 KiB | ||||
7 | Wrong answer | 3ms | 2984 KiB | ||||
8 | Wrong answer | 3ms | 3108 KiB | ||||
9 | Wrong answer | 3ms | 3344 KiB | ||||
10 | Wrong answer | 3ms | 3536 KiB | ||||
11 | Wrong answer | 3ms | 3620 KiB | ||||
12 | Wrong answer | 3ms | 3744 KiB | ||||
subtask3 | 0/7 | ||||||
13 | Wrong answer | 61ms | 20148 KiB | ||||
14 | Wrong answer | 50ms | 17868 KiB | ||||
15 | Wrong answer | 179ms | 55244 KiB | ||||
16 | Wrong answer | 740ms | 217720 KiB | ||||
17 | Time limit exceeded | 1.003s | 293428 KiB | ||||
18 | Wrong answer | 512ms | 147396 KiB | ||||
19 | Wrong answer | 515ms | 147576 KiB | ||||
20 | Wrong answer | 43ms | 16320 KiB | ||||
21 | Time limit exceeded | 1.103s | 255756 KiB | ||||
subtask4 | 0/11 | ||||||
22 | Runtime error | 358ms | 1045948 KiB | ||||
23 | Runtime error | 360ms | 1045924 KiB | ||||
24 | Runtime error | 363ms | 1045872 KiB | ||||
25 | Runtime error | 365ms | 1045868 KiB | ||||
26 | Runtime error | 361ms | 1045696 KiB | ||||
27 | Runtime error | 358ms | 1045688 KiB | ||||
subtask5 | 0/22 | ||||||
28 | Wrong answer | 298ms | 92260 KiB | ||||
29 | Wrong answer | 470ms | 143236 KiB | ||||
30 | Wrong answer | 495ms | 147944 KiB | ||||
31 | Wrong answer | 901ms | 260364 KiB | ||||
32 | Wrong answer | 162ms | 48952 KiB | ||||
33 | Wrong answer | 873ms | 229284 KiB | ||||
34 | Wrong answer | 67ms | 22012 KiB | ||||
subtask6 | 0/51 | ||||||
35 | Runtime error | 354ms | 1045708 KiB | ||||
36 | Runtime error | 352ms | 1045716 KiB | ||||
37 | Runtime error | 358ms | 1045708 KiB | ||||
38 | Runtime error | 360ms | 1045708 KiB | ||||
39 | Runtime error | 442ms | 1045644 KiB | ||||
40 | Runtime error | 356ms | 1045664 KiB | ||||
41 | Runtime error | 363ms | 1045648 KiB | ||||
42 | Runtime error | 361ms | 1045664 KiB | ||||
43 | Runtime error | 444ms | 1045648 KiB | ||||
44 | Runtime error | 365ms | 1045644 KiB | ||||
45 | Runtime error | 363ms | 1045648 KiB |