QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#184669#5561. Improving ITrgnerdplayerAC ✓71ms34348kbC++20971b2023-09-21 02:59:012023-09-21 02:59:02

Judging History

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

  • [2023-09-21 02:59:02]
  • 评测
  • 测评结果:AC
  • 用时:71ms
  • 内存:34348kb
  • [2023-09-21 02:59:01]
  • 提交

answer

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

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    auto solve = [&]() {
        int n, m;
        cin >> n >> m;

        vector<vector<pair<int, int>>> g(n + 1);

        for (int i = 1; i <= n; i++) {
            int x;
            cin >> x;
            int sz = min(m, n - i + 1);
            for (int j = 1; j <= sz; j++) {
                int y;
                cin >> y;
                g[i - 1].emplace_back(i + j - 1, x - y);
            }
        }

        vector<i64> dp(n + 1, 1e18);
        dp[0] = 0;

        for (int u = 0; u < n; u++) {
            for (auto [v, w] : g[u]) {
                dp[v] = min(dp[v], dp[u] + w);
            }
        }

        cout << dp[n] << '\n';
    };
    
    solve();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3464kb

input:

4 3
1000 900 800 900
700 600 500 400
1200 1200 1300
600 500

output:

100

result:

ok single line: '100'

Test #2:

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

input:

3 2
200 300 400
400 300 200
300 500

output:

-400

result:

ok single line: '-400'

Test #3:

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

input:

1 1
145669255 454927004

output:

-309257749

result:

ok single line: '-309257749'

Test #4:

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

input:

1 1
639426798 25010755

output:

614416043

result:

ok single line: '614416043'

Test #5:

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

input:

4 3
844421851 757954402 420571580 258916750
511274721 404934137 783798589 303312726
476596954 583382039 908112885
504686855 281837844

output:

-238707898

result:

ok single line: '-238707898'

Test #6:

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

input:

4 1
844421851 757954402
420571580 258916750
511274721 404934137
783798589 303312726

output:

834948726

result:

ok single line: '834948726'

Test #7:

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

input:

1 4
844421851 757954402

output:

86467449

result:

ok single line: '86467449'

Test #8:

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

input:

4 4
844421851 757954402 420571580 258916750 511274721
404934137 783798589 303312726 476596954
583382039 908112885 504686855
281837844 755804204

output:

-1091094209

result:

ok single line: '-1091094209'

Test #9:

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

input:

10 5
844421851 757954402 420571580 258916750 511274721 404934137
783798589 303312726 476596954 583382039 908112885 504686855
281837844 755804204 618368996 250506341 909746255 982785476
810217235 902165950 310147569 729831748 898838287 683983931
472142715 100701208 434171835 610886973 913011053 96660...

output:

-1365452778

result:

ok single line: '-1365452778'

Test #10:

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

input:

10 5
639426798 25010755 275029318 223210738 736471214 676699487
892179567 86938832 421921819 29797219 218637974 505355288
26535969 198837650 649884437 544941480 220440622 589265683
809430456 6498759 805819251 698139394 340250516 155479499
957213072 336594545 92745843 96716376 847494366 603726031
807...

output:

-425588843

result:

ok single line: '-425588843'

Test #11:

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

input:

100 50
844421851 757954402 420571580 258916750 511274721 404934137 783798589 303312726 476596954 583382039 908112885 504686855 281837844 755804204 618368996 250506341 909746255 982785476 810217235 902165950 310147569 729831748 898838287 683983931 472142715 100701208 434171835 610886973 913011053 966...

output:

-18994119385

result:

ok single line: '-18994119385'

Test #12:

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

input:

100 50
639426798 25010755 275029318 223210738 736471214 676699487 892179567 86938832 421921819 29797219 218637974 505355288 26535969 198837650 649884437 544941480 220440622 589265683 809430456 6498759 805819251 698139394 340250516 155479499 957213072 336594545 92745843 96716376 847494366 603726031 8...

output:

-17808917006

result:

ok single line: '-17808917006'

Test #13:

score: 0
Accepted
time: 22ms
memory: 6872kb

input:

1000 500
844421851 757954402 420571580 258916750 511274721 404934137 783798589 303312726 476596954 583382039 908112885 504686855 281837844 755804204 618368996 250506341 909746255 982785476 810217235 902165950 310147569 729831748 898838287 683983931 472142715 100701208 434171835 610886973 913011053 9...

output:

-199995206443

result:

ok single line: '-199995206443'

Test #14:

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

input:

1000 500
134364244 847433736 763774618 255069025 495435087 449491064 651592972 788723351 93859586 28347476 835765103 432767067 762280082 2106053 445387194 721540032 228762221 945270695 901427457 30589983 25445860 541412472 939149162 381204237 216599397 422116575 29040787 221691666 437887593 49581224...

output:

-212753922388

result:

ok single line: '-212753922388'

Test #15:

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

input:

1000 500
956034271 947827487 56551367 84871995 835498878 735969989 669730401 308136457 605944165 606801733 581204017 158382870 430669640 393531820 723012081 994819562 949395473 544177047 444854188 268240741 35924329 27444857 464893862 318465127 380014921 891789457 525752769 560510361 236123407 23858...

output:

-209586231366

result:

ok single line: '-209586231366'

Test #16:

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

input:

1000 500
237964627 544229225 369955166 603920038 625720304 65528859 13167991 837469082 259354014 234330961 995644835 470263507 836461451 476353208 639068140 150616424 634860658 868045307 523181210 741251856 671411475 64031438 758230246 591099582 301267659 31011751 865527236 472749088 718823924 87881...

output:

-207378114703

result:

ok single line: '-207378114703'

Test #17:

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

input:

1000 500
236048089 103166034 396058242 154972270 66515095 401591014 917955043 800452351 765162602 221928175 536680008 276682643 172664529 106183292 214400432 927475631 828920048 806652346 800447838 193435618 309849957 626975602 731894708 854648357 880050751 86718252 605851883 671701456 505953775 177...

output:

-216318718655

result:

ok single line: '-216318718655'

Test #18:

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

input:

1000 500
622901694 741786989 795193565 942450283 739898574 922324996 29005228 465622654 943356716 648974553 900900491 113205964 469069047 246572832 543760859 573941187 13114189 216729800 279482366 916345371 765725451 159604212 797146991 138767418 617452520 126699232 1774862 871404744 209456382 21548...

output:

-200762541639

result:

ok single line: '-200762541639'

Test #19:

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

input:

1000 500
793340083 821954042 485034627 261621482 451714 662818562 470254257 759730635 373160372 770139835 272698085 801915483 729824832 414006441 538305219 682051741 192984875 553615165 805124049 265521054 803365309 685689882 844282324 335582017 93134592 800282719 804781513 445212414 93780374 197162...

output:

-205061475065

result:

ok single line: '-205061475065'

Test #20:

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

input:

1000 500
323832764 150849173 650934473 72436286 535882004 365688916 57998924 507435733 37495658 433645683 69855423 90713013 424519189 826852124 123801961 223238964 627433222 947708942 577102948 396680474 976255105 46582680 858468459 289609286 144255083 117792238 308481824 816126359 180726379 5816001...

output:

-201088677727

result:

ok single line: '-201088677727'

Test #21:

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

input:

1000 500
226705859 962295035 126330898 704816922 85185268 247440984 999128539 209397631 641868435 459133762 453132431 494982693 192230842 830521273 89565623 234182959 19991306 266767461 407663862 902064300 379075420 113730927 258356706 991602397 63088680 620167961 377205134 660843171 338438587 69130...

output:

-197833177344

result:

ok single line: '-197833177344'

Test #22:

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

input:

1000 500
463007357 373311931 138539412 866561849 6435054 502782080 898297970 80814647 554270468 616650042 40895765 379019604 703480392 452020920 725065368 157157161 238012202 110947527 506269051 923829786 590428457 774209467 383664844 746095216 101669437 291178078 674236001 725706352 421755395 87712...

output:

-213992356177

result:

ok single line: '-213992356177'

Test #23:

score: 0
Accepted
time: 24ms
memory: 6876kb

input:

1000 500
571402594 428889054 578091301 206098232 813321251 823588872 653472533 160229556 520669359 327772811 249996676 952816909 996556992 44556382 860161037 603190610 381605985 283618217 674964847 456831151 685861485 661846320 132978144 767837813 982413249 969388160 613326820 44260632 4055144 13397...

output:

-210910630099

result:

ok single line: '-210910630099'

Test #24:

score: 0
Accepted
time: 21ms
memory: 6836kb

input:

1000 500
639426798 25010755 275029318 223210738 736471214 676699487 892179567 86938832 421921819 29797219 218637974 505355288 26535969 198837650 649884437 544941480 220440622 589265683 809430456 6498759 805819251 698139394 340250516 155479499 957213072 336594545 92745843 96716376 847494366 603726031...

output:

-204786736196

result:

ok single line: '-204786736196'

Test #25:

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

input:

1 500000
844421851 757954402

output:

86467449

result:

ok single line: '86467449'

Test #26:

score: 0
Accepted
time: 71ms
memory: 34304kb

input:

500000 1
844421851 757954402
420571580 258916750
511274721 404934137
783798589 303312726
476596954 583382039
908112885 504686855
281837844 755804204
618368996 250506341
909746255 982785476
810217235 902165950
310147569 729831748
898838287 683983931
472142715 100701208
434171835 610886973
913011053 9...

output:

-329659214483

result:

ok single line: '-329659214483'

Test #27:

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

input:

1 500000
1000000000 0

output:

1000000000

result:

ok single line: '1000000000'

Test #28:

score: 0
Accepted
time: 61ms
memory: 34348kb

input:

500000 1
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 0
10000...

output:

500000000000000

result:

ok single line: '500000000000000'

Test #29:

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

input:

3 3
3 3 3 3
4 0 0
5 0

output:

0

result:

ok single line: '0'

Test #30:

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

input:

3 3
3 2 1 0
3 2 1
3 2

output:

3

result:

ok single line: '3'