QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#252817#3146. OrangesKKT89100 ✓30ms3860kbC++171.2kb2023-11-16 12:38:492023-11-16 12:38:51

Judging History

你现在查看的是最新测评结果

  • [2023-11-16 12:38:51]
  • 评测
  • 测评结果:100
  • 用时:30ms
  • 内存:3860kb
  • [2023-11-16 12:38:49]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cassert>
#include <chrono>
#include <random>
#include <set>
#include <utility>
#include <array>
#include <bitset>
#include <unordered_set>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    ll k; cin >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<ll> dp(n+1, 1e18);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        ll mi = a[i], mx = a[i];
        for (int j = 0; j < m and i+j < n; ++j) {
            mi = min(mi, a[i+j]);
            mx = max(mx, a[i+j]);
            dp[i+j+1] = min(dp[i+j+1], dp[i]+k+(mx-mi)*(j+1));
        }
    }
    cout << dp[n] << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 0ms
memory: 3552kb

input:

19 3 5416
7452
13917
2837
220
7110
17712
9994
12084
17029
19538
5198
14849
18665
11834
4613
7785
15811
13340
16446

output:

99574

result:

ok single line: '99574'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

19 5 17582
386
14916
19226
10051
1319
8780
19283
2351
19286
15204
8066
13787
14951
19208
6330
4970
9059
16245
15105

output:

249610

result:

ok single line: '249610'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

20 5 4715
13071
6510
10382
17851
4445
12221
4103
12761
14910
9038
1827
8901
13307
7059
4427
4
4010
7709
10020
11994

output:

93116

result:

ok single line: '93116'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

20 5 16718
4675
7862
11732
12031
8379
15798
15401
16619
15051
2951
11354
18669
19132
7668
17473
7481
1926
16585
11732
7224

output:

227898

result:

ok single line: '227898'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

20 9 2535
11369
14236
19800
8262
17680
3110
8436
13691
10667
9166
14723
6395
3856
17775
2229
6268
13972
2057
13219
13317

output:

48361

result:

ok single line: '48361'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

20 9 18192
3736
6140
15204
5269
19283
8807
9015
5071
4016
8067
16609
17049
1893
14211
17210
2560
12012
5415
5621
9433

output:

244989

result:

ok single line: '244989'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

20 18 3243
1381
14024
13731
5641
6470
4332
7263
12065
2641
4766
13115
6951
17611
741
15033
2930
962
1427
15978
2720

output:

58305

result:

ok single line: '58305'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

20 20 136
7301
6307
4071
7465
14687
1934
329
18585
4247
18066
14794
15757
480
906
4116
3067
5520
6557
16316
4535

output:

2720

result:

ok single line: '2720'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

20 20 19422
13208
15485
15342
221
77
3268
7749
1650
11343
16147
6332
17441
12224
12454
10039
15291
11799
5704
14920
641

output:

250498

result:

ok single line: '250498'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

20 20 887093042
820316940
99
881723938
10
965042463
26
810548475
5
922127238
31
963896608
35
849558452
44
937390070
2
837128169
30
991813181
88

output:

17741860840

result:

ok single line: '17741860840'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

20 20 921412149
59112340
16
33476906
22
72289218
38
36759874
78
61924269
98
70145680
93
73479704
24
42083881
65
92354366
54
89538827
2

output:

2768499429

result:

ok single line: '2768499429'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

20 20 21500
19997
3
19994
1
20000
3
19992
5
19996
1
19996
2
19992
8
19999
1
19994
1
19991
8

output:

421480

result:

ok single line: '421480'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

20 5 3982
396
966
1164
1521
2998
3939
5051
5311
5848
8595
9144
11095
12161
13369
13540
13567
14039
15349
17276
18346

output:

48679

result:

ok single line: '48679'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

20 4 134357047
844185501
836411124
815453171
835816722
4942714
14266220
26812420
5896357
95998202
868065746
862664859
890501896
851172982
30364076
75564751
79556375
77770357
814069429
821890102
856426492

output:

1439269190

result:

ok single line: '1439269190'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

20 15 71117844
830938792
848125947
874559232
837433580
53444523
1368810
47334494
11231236
896483484
875338933
87469915
98237135
95751807
98796785
833435950
880848530
822952244
891895593
84292035
859402847

output:

1181559634

result:

ok single line: '1181559634'

Subtask #2:

score: 50
Accepted

Dependency #1:

100%
Accepted

Test #16:

score: 50
Accepted
time: 0ms
memory: 3788kb

input:

1998 51 55160352
798589904
793385330
8300886
11809829
101990437
776354192
381052749
25576512
149599594
333598481
247327909
424868959
481943142
968659340
85231456
502819089
880167283
31888727
7160083
543640722
837633320
364107866
198275520
186890586
430676039
547743865
798519085
409153080
730351820
3...

output:

107144540774

result:

ok single line: '107144540774'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

2000 49 18728602
554162895
153047226
548343404
798464324
365067405
100074555
651585861
118739822
969896802
112966697
469708978
872362455
896348996
907793937
375613051
981726453
747194728
683519562
665649143
477983118
682982507
293137229
489622077
779171591
812825894
219609270
16426276
795247117
2534...

output:

37182964662

result:

ok single line: '37182964662'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

2000 100 56148853
812713036
50101012
746181873
718295866
909691765
651230410
359824433
620387709
157730562
139522850
308049244
723060212
205879248
20055580
357587071
4156800
440758546
10603033
977860298
733951408
726275209
877810907
211711851
158181165
689739834
34592557
569007367
667541693
99309742...

output:

109555639200

result:

ok single line: '109555639200'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

2000 98 90585404
141665395
294508735
751531886
345001489
573126530
683089796
494357368
22742652
634996759
175709673
634928875
146120214
214346413
846254256
14750873
679660118
34133757
109942041
588174154
393138212
614051553
178236395
529744811
362278170
741834349
378736940
695369668
652922200
333803...

output:

173061694586

result:

ok single line: '173061694586'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

2000 41 868988961
454826914
321514581
93468950
801727672
391634051
281671389
18636210
171737024
50591159
952334358
296677913
695601903
347694727
193609997
638998080
807267035
475172316
34747924
131941065
637378163
350976093
863815567
956435714
875810857
902820040
57507339
124105242
799475494
9441081...

output:

1139002754885

result:

ok single line: '1139002754885'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

1999 99 807620495
281965662
414202429
277458971
745103237
170364382
760096210
305268570
555318993
503431381
143591723
34151662
407059881
75819556
714995947
604139377
110231781
946204163
52261629
77530231
208465626
497500861
137041088
9062275
610948604
700929501
564255683
735806913
527860262
88662185...

output:

1092843375416

result:

ok single line: '1092843375416'

Test #22:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

2000 97 546380455
500197097
150395717
85185770
999828227
348022121
807906288
419399121
662466341
828799986
873628590
549988403
577298560
945363375
750587668
1397637
445680311
574307369
692382383
233626674
999216680
745132738
72373696
795192188
542519139
54241520
4636992
874546669
74875844
820697564
...

output:

834191312135

result:

ok single line: '834191312135'

Test #23:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

2000 96 796676719
781337326
752886608
957448869
275208983
689587725
851596986
441436166
971268295
144223606
5387960
343230356
154195955
731433837
352399988
821593743
524947443
594099019
161891576
370838443
917504193
847486576
382375739
290509065
825141204
187073151
585453196
958345101
230526218
8030...

output:

1100207515157

result:

ok single line: '1100207515157'

Test #24:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

2000 99 536567040
670393786
381332608
795816037
118545363
637934941
809780575
122178095
93172893
315909095
719831127
845986375
92616819
553911076
775228236
410134001
644856854
10868485
468539059
631799539
429376847
759171163
197433674
135074261
408527139
193998969
496631613
881958865
218781543
78896...

output:

824612138819

result:

ok single line: '824612138819'

Test #25:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

2000 98 947866077
959820004
839527838
814528897
51901789
154954952
485928383
73611659
189854050
919103797
791226583
802099935
407892989
987477201
83507500
602713712
10281619
210422324
531613511
185659524
228679079
944753045
918991910
556027068
411167842
215411147
159363393
383504995
303204614
353073...

output:

1225615825102

result:

ok single line: '1225615825102'

Test #26:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

2000 50 109684396
803185316
63
148411185
23
544301510
1
358838345
47
708601346
35
945295497
49
317508662
83
936685717
69
595305510
43
164542296
60
680958609
15
382826976
35
395128728
89
848797721
84
947988448
88
227685684
83
687792541
62
584961601
47
414146938
62
268241904
98
164952419
43
382786841
...

output:

219368792000

result:

ok single line: '219368792000'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

2000 100 941541806
98752843
80
99101202
76
94197103
48
95635215
84
69300476
75
31254477
33
81101355
58
68706155
40
87137405
100
94002595
38
73430436
7
91452531
37
75672766
47
66941929
77
90815796
13
57498790
65
86694153
26
75365470
42
42392286
88
89651173
90
54887651
11
35635075
29
64966156
1
561376...

output:

215373937617

result:

ok single line: '215373937617'

Test #28:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

1999 51 3893063
12086
42558
52871
64139
64575
64685
81625
83236
84840
86671
96498
96866
106633
117798
139006
150471
161490
181026
211371
211561
229388
231997
233440
242232
243514
243666
247406
250032
258946
280935
283520
295224
307809
312716
333038
338827
345679
348612
354048
361219
377925
390200
39...

output:

726782808

result:

ok single line: '726782808'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

1998 70 122586666
818669609
867145070
898630243
814820768
820209448
834997202
850689084
892471776
837899832
873253626
874380369
840718625
843336112
816294066
809804566
866910072
896434379
868851000
892560546
805952410
884293491
877169555
818253719
825485076
834998968
849993253
861392714
877481215
80...

output:

142339107271

result:

ok single line: '142339107271'

Test #30:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

1999 59 75177136
809881169
872218340
827033153
891700707
881110727
836229148
800039163
877627630
868022760
829416548
891360357
810008477
854971649
845992591
891188998
846959993
855356619
839092313
876777085
841634612
833071943
856241429
804737670
845250282
808541935
823192709
855855495
841178331
862...

output:

106041794299

result:

ok single line: '106041794299'

Subtask #3:

score: 30
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #31:

score: 30
Accepted
time: 16ms
memory: 3532kb

input:

19998 498 54326973
80665821
571098288
213770561
293417967
400862650
864677
362494629
153926734
377224520
618156246
622149480
743806126
707533203
150417071
345880580
843672501
58666654
131347014
751892318
812242864
618895958
846816305
316073264
405400337
873331609
185304012
140352418
840271964
915148...

output:

1055745509210

result:

ok single line: '1055745509210'

Test #32:

score: 0
Accepted
time: 19ms
memory: 3600kb

input:

19998 499 83217609
514759259
465387372
218087377
676948910
904990706
499147283
447083763
923119076
675084568
670290988
928369814
10310662
529208674
80221245
758261483
138852354
641814989
894110885
761833246
402054447
124768901
393312972
14697859
127846155
364340031
831210272
762142135
749948214
8892...

output:

1593376445399

result:

ok single line: '1593376445399'

Test #33:

score: 0
Accepted
time: 29ms
memory: 3596kb

input:

19998 998 78092696
937422408
81952328
141933011
884303394
917206929
799667218
448691415
569056875
216804181
669272929
576252308
713020087
224210182
315989461
262391261
359793572
359124698
930367406
327843273
977385318
698425768
797895951
350718440
597850331
786183900
651252162
158824295
839283872
97...

output:

1502484805833

result:

ok single line: '1502484805833'

Test #34:

score: 0
Accepted
time: 30ms
memory: 3548kb

input:

19999 999 24724113
124462396
272867077
839975917
529803011
868558536
903580835
260004011
138451666
377876298
404285209
911464888
925830204
639692174
711570573
669390961
275717205
314395765
428618998
659904952
677260522
275837969
361666126
149086156
389158574
972781066
426459002
327518069
221631922
8...

output:

488539181313

result:

ok single line: '488539181313'

Test #35:

score: 0
Accepted
time: 16ms
memory: 3596kb

input:

19999 490 375993880
494699744
468728700
261782461
310113026
598325331
773205166
26748218
107342278
502614320
113161310
127641836
85838161
945953904
829892152
956459299
847995110
358350545
601750571
947863963
849533555
833630897
75845467
566738111
263998187
305868390
742607094
754073943
980267295
635...

output:

6234422035891

result:

ok single line: '6234422035891'

Test #36:

score: 0
Accepted
time: 26ms
memory: 3812kb

input:

19999 999 235998190
684152219
937070946
796283135
56269486
835970954
33239907
395413074
865442887
951573617
915219520
64611823
895748091
770668359
442361396
375268112
327338942
93900583
66595221
483701609
525195723
504738308
156508213
930297073
213778355
397584928
903037780
12985747
217847388
188577...

output:

4198289546612

result:

ok single line: '4198289546612'

Test #37:

score: 0
Accepted
time: 29ms
memory: 3828kb

input:

20000 991 771425940
249371207
543677575
662104738
458069578
891132514
509312401
713109244
673589071
866278089
125023274
712066200
417519001
618587296
157837155
38849864
384131544
532590583
996174237
769190510
923944296
804201997
76163231
544068666
957482647
268163784
811496804
708870790
947690022
46...

output:

10711227146774

result:

ok single line: '10711227146774'

Test #38:

score: 0
Accepted
time: 25ms
memory: 3616kb

input:

20000 994 518117358
236359169
560022992
41717125
211509060
533513097
162623070
482907309
967381927
158294743
511491106
264018852
739233549
644982690
119534306
675195578
672328025
459126624
264299175
827253943
570219351
60740199
929521739
665357887
913581557
237862498
126275491
123614920
446513888
45...

output:

8082927294616

result:

ok single line: '8082927294616'

Test #39:

score: 0
Accepted
time: 29ms
memory: 3828kb

input:

20000 999 580391054
746811094
694585295
775197265
740191001
88150815
204638445
142230917
15747385
221125792
824676184
334932835
505357826
570801213
132397383
56217842
179713474
66029969
294841878
267784338
795783660
509056555
846266547
424151192
566904300
129583273
621130822
826061850
284877005
5999...

output:

8815134220695

result:

ok single line: '8815134220695'

Test #40:

score: 0
Accepted
time: 27ms
memory: 3816kb

input:

20000 919 997487531
775223850
263287915
579946696
94129001
242683762
568793167
951576043
476107002
829632248
12555825
648091078
585141741
407641415
305740439
765824294
138259254
679612915
532484355
681472762
456058155
639466123
269903559
316473006
684046647
169925297
721273146
248210330
330412515
32...

output:

12662217865007

result:

ok single line: '12662217865007'

Test #41:

score: 0
Accepted
time: 14ms
memory: 3524kb

input:

20000 500 408723558
122908601
51
729772334
91
736921405
66
474923516
80
927417751
65
737863327
47
665515607
99
732332870
31
856605808
51
437054885
13
560074143
15
964191383
40
669806588
40
661781425
77
434898113
44
601586055
54
933123445
57
107429957
60
510772164
62
248028293
24
348444736
94
1425899...

output:

7657574697019

result:

ok single line: '7657574697019'

Test #42:

score: 0
Accepted
time: 29ms
memory: 3620kb

input:

20000 1000 985220370
52512642
93
36566407
94
90951248
52
78829578
16
85876319
37
36459317
41
83889569
4
50658339
52
40996021
36
98745019
65
32889469
61
81630797
66
49007119
88
93590993
69
99856521
3
78523778
1
95451044
71
68090380
51
87839024
39
80072718
68
97688097
68
47596290
82
44034078
45
382640...

output:

2014930307896

result:

ok single line: '2014930307896'

Test #43:

score: 0
Accepted
time: 16ms
memory: 3676kb

input:

19991 510 3844312
3849
4829
5262
7059
10438
12149
13609
14714
14719
16650
18882
19092
20503
20710
22086
22340
22519
22906
22956
23030
26009
26049
26799
27371
27896
30262
32438
34635
34700
36082
36093
36899
37105
37384
40124
41767
44706
45010
45064
45223
45634
45771
46347
46398
48939
50242
50879
5459...

output:

2402711541

result:

ok single line: '2402711541'

Test #44:

score: 0
Accepted
time: 23ms
memory: 3552kb

input:

19984 776 133830453
844299677
820763221
820828137
885421002
870223017
887803814
835348942
895975821
873548025
820617871
823560905
835171148
884530518
835301137
819710822
886604124
831727512
839555962
824914544
816210831
823943208
832933907
811195326
896568335
824253715
862690896
833095246
856403574
...

output:

1498941070597

result:

ok single line: '1498941070597'

Test #45:

score: 0
Accepted
time: 14ms
memory: 3700kb

input:

19929 592 65421728
800190418
875250434
800042455
854041546
866143615
857271483
876074887
895015358
835371235
810892152
842840846
840924701
850570358
851898424
862100495
887859929
801223854
889081050
828955986
849128246
801573209
883088902
864526394
830872604
872867944
877104587
899410462
841187076
8...

output:

957177938582

result:

ok single line: '957177938582'

Extra Test:

score: 0
Extra Test Passed