105412024-04-04 20:16:09111Az IKPC legerősebb csapatacpp17Wrong answer 0/1001.103s1045948 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1828 KiB
2Wrong answer3ms2048 KiB
subtask20/9
3Wrong answer3ms2260 KiB
4Wrong answer3ms2464 KiB
5Wrong answer3ms2684 KiB
6Wrong answer3ms2764 KiB
7Wrong answer3ms2984 KiB
8Wrong answer3ms3108 KiB
9Wrong answer3ms3344 KiB
10Wrong answer3ms3536 KiB
11Wrong answer3ms3620 KiB
12Wrong answer3ms3744 KiB
subtask30/7
13Wrong answer61ms20148 KiB
14Wrong answer50ms17868 KiB
15Wrong answer179ms55244 KiB
16Wrong answer740ms217720 KiB
17Time limit exceeded1.003s293428 KiB
18Wrong answer512ms147396 KiB
19Wrong answer515ms147576 KiB
20Wrong answer43ms16320 KiB
21Time limit exceeded1.103s255756 KiB
subtask40/11
22Runtime error358ms1045948 KiB
23Runtime error360ms1045924 KiB
24Runtime error363ms1045872 KiB
25Runtime error365ms1045868 KiB
26Runtime error361ms1045696 KiB
27Runtime error358ms1045688 KiB
subtask50/22
28Wrong answer298ms92260 KiB
29Wrong answer470ms143236 KiB
30Wrong answer495ms147944 KiB
31Wrong answer901ms260364 KiB
32Wrong answer162ms48952 KiB
33Wrong answer873ms229284 KiB
34Wrong answer67ms22012 KiB
subtask60/51
35Runtime error354ms1045708 KiB
36Runtime error352ms1045716 KiB
37Runtime error358ms1045708 KiB
38Runtime error360ms1045708 KiB
39Runtime error442ms1045644 KiB
40Runtime error356ms1045664 KiB
41Runtime error363ms1045648 KiB
42Runtime error361ms1045664 KiB
43Runtime error444ms1045648 KiB
44Runtime error365ms1045644 KiB
45Runtime error363ms1045648 KiB