UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207892#3756. 氪金wyz_100250ms1320kbC++11652b2024-08-01 09:25:052024-08-01 12:05:57

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int n,k;
ll dp[9005];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	memset(dp,-1,sizeof dp);
	dp[0] = 0;
	
	cin >> n >> k;
	while(n--){
		int a,b,c;
		cin >> a >> b >> c;
		
		for(int i = k; i >= 1; i--){
			if(0 <= i-1 && dp[i-1] != -1)
				dp[i] = min(dp[i] == -1 ? LLONG_MAX : dp[i], a + dp[i-1]);
			if(0 <= i-2 && dp[i-2] != -1)
				dp[i] = min(dp[i] == -1 ? LLONG_MAX : dp[i], b + dp[i-2]);
			if(0 <= i-3 && dp[i-3] != -1)
				dp[i] = min(dp[i] == -1 ? LLONG_MAX : dp[i], c + dp[i-3]);
		}
	}
	
	cout << dp[k];
	
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1316kb

input:

10 19
25 43 45
4 14 24
32 38 49
17 29 47
15 20 46
21 29 44
16 23 44
3 36 43
12 23 46
16 22 25

output:

207

result:

ok single line: '207'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1312kb

input:

10 23
28 29 46
8 14 24
38 43 45
20 24 26
18 34 50
19 40 48
6 12 48
15 19 46
19 28 37
5 10 29

output:

250

result:

ok single line: '250'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1316kb

input:

10 27
5 16 41
9 13 15
36 46 47
5 17 34
2 11 46
1 5 18
19 25 28
35 39 48
20 34 45
5 29 40

output:

285

result:

ok single line: '285'

Test #4:

score: 10
Accepted
time: 1ms
memory: 1316kb

input:

200 240
427036 657838 749396
298365 618527 628027
428349 528817 652790
141804 460422 854755
162095 2...

output:

30545586

result:

ok single line: '30545586'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1320kb

input:

200 237
375521 483421 759165
88918 143306 597322
424599 609056 748361
723374 752223 779018
640609 71...

output:

30687218

result:

ok single line: '30687218'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1320kb

input:

200 370
513967 743968 790884
409190 543286 605898
63667 336942 923057
327320 397203 423043
488223 89...

output:

64588769

result:

ok single line: '64588769'

Test #7:

score: 10
Accepted
time: 78ms
memory: 1316kb

input:

3000 7284
85524758 115426324 505752134
12429051 291488711 775034760
254227206 516881688 906255233
29...

output:

1482432506136

result:

ok single line: '1482432506136'

Test #8:

score: 10
Accepted
time: 54ms
memory: 1320kb

input:

3000 3898
161797064 246791608 433818711
8165667 335935487 753536978
154845210 163255536 626512895
76...

output:

528701120806

result:

ok single line: '528701120806'

Test #9:

score: 10
Accepted
time: 48ms
memory: 1316kb

input:

3000 4057
45594024 488053571 767918809
77657192 211075988 228104479
337726140 561192252 607760601
19...

output:

553851342377

result:

ok single line: '553851342377'

Test #10:

score: 10
Accepted
time: 69ms
memory: 1316kb

input:

3000 6206
65387721 461045368 582079356
91325589 498569972 966744114
449773293 501141361 917627284
86...

output:

1151101483840

result:

ok single line: '1151101483840'

Extra Test:

score: 0
Extra Test Passed