105422024-04-04 20:16:43111Az IKPC legerősebb csapatacpp17Wrong answer 0/100446ms1046884 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2024 KiB
subtask20/9
3Accepted3ms2236 KiB
4Wrong answer3ms2340 KiB
5Wrong answer3ms2568 KiB
6Accepted3ms2768 KiB
7Accepted3ms2984 KiB
8Wrong answer3ms3204 KiB
9Wrong answer3ms3432 KiB
10Accepted2ms3504 KiB
11Wrong answer3ms3632 KiB
12Wrong answer2ms3712 KiB
subtask30/7
13Accepted10ms19956 KiB
14Wrong answer9ms17880 KiB
15Wrong answer29ms54632 KiB
16Accepted116ms217088 KiB
17Accepted156ms292972 KiB
18Wrong answer79ms146692 KiB
19Wrong answer79ms146696 KiB
20Wrong answer9ms15524 KiB
21Accepted273ms506568 KiB
subtask40/11
22Runtime error356ms1046884 KiB
23Runtime error354ms1046864 KiB
24Runtime error360ms1046836 KiB
25Runtime error358ms1046832 KiB
26Runtime error356ms1046708 KiB
27Runtime error352ms1046712 KiB
subtask50/22
28Wrong answer50ms91124 KiB
29Accepted76ms142200 KiB
30Accepted79ms146868 KiB
31Wrong answer143ms259388 KiB
32Wrong answer27ms47904 KiB
33Wrong answer123ms228216 KiB
34Wrong answer13ms21072 KiB
subtask60/51
35Runtime error356ms1046724 KiB
36Runtime error354ms1046728 KiB
37Runtime error358ms1046704 KiB
38Runtime error354ms1046696 KiB
39Runtime error356ms1046684 KiB
40Runtime error360ms1046664 KiB
41Runtime error358ms1046676 KiB
42Runtime error358ms1046668 KiB
43Runtime error446ms1046440 KiB
44Runtime error356ms1046444 KiB
45Runtime error358ms1046440 KiB