QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#305906 | #6122. Impossible-to-finish Race | ckiseki | AC ✓ | 30ms | 3972kb | C++20 | 734b | 2024-01-16 06:02:11 | 2024-01-16 06:02:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t INF = 1e18;
void chmax(int64_t &x, int64_t v) {
x = max(x, v);
}
signed main() {
cin.tie(nullptr) -> sync_with_stdio(false);
int S, N;
cin >> S >> N;
vector<pair<int,int>> people(S);
for (auto &[H, A]: people) {
cin >> A >> H;
}
sort(people.begin(), people.end());
int64_t ans = -INF;
vector<int64_t> dp(N + 1, -INF);
for (auto [H, A]: people) {
auto ndp = dp;
for (int j = N - 1; j >= 1; j--) {
chmax(ndp[j + 1], dp[j] + A);
}
chmax(ndp[1], A + H);
dp = ndp;
chmax(ans, dp[N] - H);
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
4 2 40 150 100 185 60 160 80 170
output:
165
result:
ok 1 number(s): "165"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
4 3 40 150 100 185 60 160 80 170
output:
215
result:
ok 1 number(s): "215"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4 3 40 150 100 300 60 160 80 140
output:
160
result:
ok 1 number(s): "160"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
10 5 31 41 59 26 53 58 97 93 23 84 62 64 33 83 27 95 2 84 19 71
output:
237
result:
ok 1 number(s): "237"
Test #5:
score: 0
Accepted
time: 7ms
memory: 3556kb
input:
41152 111 182257016 930588061 48161946 238486760 972227016 5356065 86027096 260499041 669036106 225099150 237412554 751531756 242943966 295403431 389306712 171941587 805402434 808802744 223087510 185548988 484802407 630362813 909265069 146703978 669049492 795632652 880214973 687316602 917988759 1140...
output:
110260223222
result:
ok 1 number(s): "110260223222"
Test #6:
score: 0
Accepted
time: 13ms
memory: 3560kb
input:
48742 151 4172512 232468953 174593775 315428416 755598560 502830675 153875037 669103745 655189533 251356834 742835852 504736254 57702809 81033220 522268929 496624663 916420651 11925854 636090457 18793771 59670306 212773533 266630484 168697702 249848762 90639194 167795884 521046550 275829432 75048104...
output:
150042793971
result:
ok 1 number(s): "150042793971"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
10832 185 384369718 813482411 710792603 515157830 552246538 364938172 118387323 558137174 960264583 110630 883245504 400769573 912502469 245524014 160032703 685924756 784192091 291966573 855188194 828271633 957837360 194604250 571403510 177773109 746568096 669989013 294755059 430843816 570306962 862...
output:
182319609909
result:
ok 1 number(s): "182319609909"
Test #8:
score: 0
Accepted
time: 5ms
memory: 3600kb
input:
18148 181 317375491 959619539 283021787 485619692 474951974 984085468 295380316 824207087 152625734 650222645 190338285 195156360 311736957 338390028 289661673 796666562 605193885 709391445 466977224 332169628 524062708 562163672 676469373 606455442 487555874 770717667 492775549 65447403 154084339 9...
output:
179257349651
result:
ok 1 number(s): "179257349651"
Test #9:
score: 0
Accepted
time: 5ms
memory: 3556kb
input:
20517 119 81770998 83447880 733395187 340904766 51692224 631824159 247762158 720798400 753102635 46716151 400316097 440030572 411675274 726057252 881612034 894407953 681714230 187307136 951565981 858102613 570176402 341903964 829157317 310766291 226552528 637766332 733441545 358801637 414258293 6001...
output:
117841021264
result:
ok 1 number(s): "117841021264"
Test #10:
score: 0
Accepted
time: 26ms
memory: 3844kb
input:
93044 182 813695274 153887021 542126825 663951320 364280184 904341637 291766688 257121248 75639269 180912022 825451471 22204002 473902802 454694292 611075180 805611054 844482533 903659112 773663466 532233047 138575839 944906705 668819264 137394165 225354534 384383944 510444964 359732925 763300639 60...
output:
181211463696
result:
ok 1 number(s): "181211463696"
Test #11:
score: 0
Accepted
time: 6ms
memory: 3780kb
input:
25784 53 798294768 320766717 429746760 294501271 644419286 801462427 724066936 339399074 657789061 573676913 970005050 661268530 426332867 254169739 153700078 827586236 289134392 246530412 788279593 302899440 39720539 183658008 615865661 431061664 941027421 67440607 851264422 537004856 427260246 891...
output:
52567930451
result:
ok 1 number(s): "52567930451"
Test #12:
score: 0
Accepted
time: 18ms
memory: 3936kb
input:
85083 117 933728908 166830648 315791188 439632784 325837679 115125521 270329800 873456540 640213196 243297796 914696498 111637314 824743768 733251609 879223039 702511677 601533585 506847766 388042178 540773701 584502053 164333442 235718823 825003326 160442761 580351903 112999161 343919921 120241611 ...
output:
116486732641
result:
ok 1 number(s): "116486732641"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3812kb
input:
21476 97 63429284 292081968 724418165 393470825 255101780 520874265 537856330 530859115 387052107 227378228 955779689 938747569 362382510 470288870 758017146 980866850 95193697 896397143 347630065 188685241 993612425 674170903 335151627 886335139 549751105 54769792 966979302 796574615 770088067 1448...
output:
96145475777
result:
ok 1 number(s): "96145475777"
Test #14:
score: 0
Accepted
time: 20ms
memory: 3836kb
input:
96285 26 455028034 39251727 824295989 385236424 63399198 102638857 387334356 581156661 454974662 709028736 900399312 684211451 149763651 644418604 32511388 718985488 660630420 211641780 486912715 466693387 686434645 485294856 493518359 822845210 221767398 816352162 507764176 223798302 47074048 79690...
output:
25916772196
result:
ok 1 number(s): "25916772196"
Test #15:
score: 0
Accepted
time: 22ms
memory: 3884kb
input:
100000 200 236287670 804039413 140506636 670751691 331381204 895007340 852265703 736737899 804066444 277236557 237844614 812494506 55084996 90201715 876812302 513418441 584034127 726487185 844521069 244127643 361613896 694711811 154016310 831976968 244847489 447480031 424060659 682670356 139039667 9...
output:
199215953571
result:
ok 1 number(s): "199215953571"
Test #16:
score: 0
Accepted
time: 30ms
memory: 3764kb
input:
100000 200 438541603 699411539 45417102 957932414 304996950 512547237 584684086 961533781 85093785 624474586 91726999 104157166 291779221 957187862 786912201 353204590 400062744 185413463 694278118 784865714 851265992 756883083 536887012 820028712 190249867 137695614 722578103 999507904 301485310 35...
output:
199134024482
result:
ok 1 number(s): "199134024482"
Test #17:
score: 0
Accepted
time: 30ms
memory: 3816kb
input:
100000 200 7869483 240665921 517875314 503237636 3205902 925930729 143045670 194790167 330039680 721900494 63022288 593543362 941594188 927093988 920949625 753039988 853635654 294002372 65745113 167910923 237381758 796352381 967179707 239125243 988173949 818397040 425777074 96442630 51201807 4944016...
output:
199126570851
result:
ok 1 number(s): "199126570851"
Test #18:
score: 0
Accepted
time: 30ms
memory: 3860kb
input:
100000 200 902153908 142027280 491509782 851124712 6599211 436319431 913466861 322115820 57493938 710409781 74833645 399824586 562099895 427843643 14156121 864906695 830614130 723066316 669677424 572708011 937925307 6248069 722530198 429178594 616408073 911018995 797450175 679990995 712580391 689235...
output:
199142450154
result:
ok 1 number(s): "199142450154"
Test #19:
score: 0
Accepted
time: 30ms
memory: 3804kb
input:
100000 200 939641504 778976225 778616835 2958301 368789217 929481585 427443141 605128056 331854886 134924969 908388080 427473861 203966828 516359881 942628120 182970193 321917044 900091744 616518555 532100761 665778808 981854704 866908765 109120055 489523878 899555399 974545907 788211427 610866724 6...
output:
199177375050
result:
ok 1 number(s): "199177375050"
Test #20:
score: 0
Accepted
time: 29ms
memory: 3812kb
input:
100000 200 583328109 554198621 562525804 662027941 725614636 75659819 948042884 477667597 596983489 886129587 792076150 150285026 462832527 880401700 334081616 953611058 268591216 657464705 6154469 576624039 718168742 157125273 475875972 528059530 933799823 886898046 164353212 854376951 263532606 33...
output:
199175464473
result:
ok 1 number(s): "199175464473"
Test #21:
score: 0
Accepted
time: 30ms
memory: 3792kb
input:
100000 200 808513977 693609959 113456635 805685032 749222875 784057935 512349672 480807957 190888767 553755075 549381310 417267049 688640871 688573004 248221644 502151017 158194613 184746652 738824951 167915607 55980081 95216084 838640235 199108433 116057004 899224809 503327466 718196997 226537968 9...
output:
199136249264
result:
ok 1 number(s): "199136249264"
Test #22:
score: 0
Accepted
time: 30ms
memory: 3888kb
input:
100000 200 449001049 695315428 978310626 438967643 795100890 183356799 190894562 276681907 649706302 73327984 903229801 421547301 746685377 741806243 541298524 356085904 898002540 507512328 24664064 798539118 688386794 854172435 824926706 104337396 892307134 162706216 788773015 63384255 487326808 86...
output:
199169029575
result:
ok 1 number(s): "199169029575"
Test #23:
score: 0
Accepted
time: 29ms
memory: 3972kb
input:
100000 200 444178781 356527699 529067437 801914346 665271123 538072264 956196567 812162423 615549469 549136686 939822396 465446774 265968471 255876890 372664828 265062579 524359005 914735255 472087053 67462564 703870929 115331092 804397128 361386687 762455723 702740230 41107646 323309719 146634035 7...
output:
199146249202
result:
ok 1 number(s): "199146249202"
Test #24:
score: 0
Accepted
time: 27ms
memory: 3968kb
input:
100000 200 655846365 313661203 390366508 158862627 527184479 984287389 309597946 579207531 794937319 321271765 706090082 948555033 618523013 107471453 621983726 940529266 562426216 415859210 321935327 513511252 748344017 347120895 217118746 322199855 81080463 967391225 258456215 820218495 787827813 ...
output:
199199818297
result:
ok 1 number(s): "199199818297"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 2 1 1000000000 1000000000 1
output:
2
result:
ok 1 number(s): "2"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
2 2 1 1000000000 1 1
output:
-999999997
result:
ok 1 number(s): "-999999997"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
200 200 832389878 271044862 71070899 504340371 912900693 325041542 504067161 271327382 833455367 394595095 506978832 240062738 734214661 504285209 717534322 482651310 510898733 872555736 175301434 768829912 391606846 13107072 393006456 974016395 448546064 822560580 676221324 805445063 407319269 2530...
output:
107479788170
result:
ok 1 number(s): "107479788170"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
200 200 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...
output:
200000000000
result:
ok 1 number(s): "200000000000"
Test #29:
score: 0
Accepted
time: 30ms
memory: 3808kb
input:
100000 200 1000000000 78517909 1000000000 500311177 1000000000 293785522 1000000000 954237907 1000000000 882968874 1000000000 134408655 1000000000 552621244 1000000000 19461143 1000000000 951319484 1000000000 873867203 1000000000 933129813 1000000000 824346657 1000000000 305877734 1000000000 9029348...
output:
199998531281
result:
ok 1 number(s): "199998531281"
Test #30:
score: 0
Accepted
time: 30ms
memory: 3836kb
input:
100000 200 113401148 1000000000 910622498 1000000000 437673863 1000000000 94487241 1000000000 254064871 1000000000 457253831 1000000000 567763265 1000000000 816041200 1000000000 340366554 1000000000 725083245 1000000000 437112787 1000000000 478317431 1000000000 122307300 1000000000 558373892 1000000...
output:
199818861002
result:
ok 1 number(s): "199818861002"