UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207837#3756. 氪金Allen123456hello100377ms1332kbC++11564b2024-08-01 08:44:092024-08-01 12:02:02

answer

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
typedef long long LL;
int n,k;
LL a,b,c,dp[2][9005];
bool pos=0;
int main(){
    scanf("%d%d",&n,&k);
    memset(dp,0x3f,sizeof dp);
    dp[0][0]=0;
    for (int i=1;i<=n;++i){
        pos=!pos;
        scanf("%lld%lld%lld",&a,&b,&c);
        for (int j=0;j<=k;++j){
            dp[pos][j]=min({dp[!pos][j],j>=1?(dp[!pos][j-1]+a):0x3f3f3f3f,j>=2?(dp[!pos][j-2]+b):0x3f3f3f3f,j>=3?(dp[!pos][j-3]+c):0x3f3f3f3f});
        }
    }
    printf("%lld",dp[pos][k]);
    return 0;
}

详细

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

Test #1:

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

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: 1332kb

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: 1ms
memory: 1328kb

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: 0ms
memory: 1332kb

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: 1332kb

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: 1328kb

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: 132ms
memory: 1328kb

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: 64ms
memory: 1328kb

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: 74ms
memory: 1328kb

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: 106ms
memory: 1328kb

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