105442024-04-04 20:21:35111Az IKPC legerősebb csapatacpp17Wrong answer 0/100423ms1047084 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2056 KiB
subtask20/9
3Accepted3ms2288 KiB
4Wrong answer3ms2464 KiB
5Wrong answer3ms2568 KiB
6Accepted3ms2776 KiB
7Accepted3ms2988 KiB
8Wrong answer3ms3216 KiB
9Wrong answer2ms3324 KiB
10Accepted3ms3428 KiB
11Wrong answer3ms3512 KiB
12Wrong answer2ms3592 KiB
subtask30/7
13Accepted10ms19744 KiB
14Wrong answer9ms17504 KiB
15Wrong answer32ms54348 KiB
16Accepted123ms216804 KiB
17Accepted164ms292708 KiB
18Wrong answer82ms146588 KiB
19Wrong answer82ms146588 KiB
20Wrong answer9ms15560 KiB
21Accepted287ms506560 KiB
subtask40/11
22Runtime error358ms1047084 KiB
23Runtime error358ms1047052 KiB
24Runtime error361ms1047032 KiB
25Runtime error423ms1047016 KiB
26Runtime error361ms1047016 KiB
27Runtime error363ms1046988 KiB
subtask50/22
28Wrong answer52ms90824 KiB
29Accepted81ms142016 KiB
30Accepted83ms146924 KiB
31Wrong answer150ms259188 KiB
32Wrong answer28ms47736 KiB
33Wrong answer128ms228144 KiB
34Wrong answer13ms20832 KiB
subtask60/51
35Runtime error360ms1046816 KiB
36Runtime error361ms1046776 KiB
37Runtime error361ms1046784 KiB
38Runtime error361ms1046756 KiB
39Runtime error361ms1046752 KiB
40Runtime error363ms1046744 KiB
41Runtime error363ms1046736 KiB
42Runtime error358ms1046752 KiB
43Runtime error363ms1046744 KiB
44Runtime error363ms1046744 KiB
45Runtime error361ms1046744 KiB