QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#546091 | #1808. Efficient Partitioning | surgutti# | AC ✓ | 1496ms | 15044kb | C++17 | 815b | 2024-09-03 19:42:19 | 2024-09-03 19:42:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n), b(n), c(n);
for (int &x : a)
cin >> x;
for (int &x : b)
cin >> x;
for (int &x : c)
cin >> x;
auto check = [&](long long x) {
set<long long> S;
long long offset = 0;
S.emplace(b[0]);
for (int i = 0; i < n; i++) {
offset += a[i] + c[i];
if (i > 0) {
offset -= c[i - 1];
}
if (*S.rbegin() + offset >= x && i + 1 < n) {
S.emplace(b[i + 1] - offset + c[i]);
}
}
return *S.rbegin() + offset >= x;
};
long long l = -1e18L, r = +1e18L;
while (r - l > 1) {
long long m = (l + r) >> 1;
if (check(m))
l = m;
else
r = m;
}
cout << l << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3476kb
input:
2 1 -1 -1 4 1 -2
output:
1
result:
ok answer is '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
1 1000000000 1000000000 1000000000
output:
3000000000
result:
ok answer is '3000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
11 -323225375 -897098227 -795978453 501188072 409939326 -362890219 969123048 962633819 252457646 694824070 -406990840 -696821643 -663750226 -570551722 670541392 172964990 399404695 -305728788 -157617655 -801518744 -328729631 -160335217 -465411342 -660775657 515997870 -34787742 628368976 84800619 -72...
output:
91174984
result:
ok answer is '91174984'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
2 12 3 -13 -1 -19 7
output:
9
result:
ok answer is '9'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
9 -13 -10 18 4 -9 8 -12 18 1 3 3 7 10 -16 -10 8 -7 -19 -20 15 -17 2 7 15 11 14 8
output:
16
result:
ok answer is '16'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
10 -3 -20 -13 19 -12 2 -15 -9 -12 -15 8 20 8 19 9 -13 8 16 10 8 12 8 7 14 -1 -11 -7 -6 4 -7
output:
-14
result:
ok answer is '-14'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
2 -17 -12 -4 15 1 -13
output:
-20
result:
ok answer is '-20'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
6 2 -7 18 -14 9 -3 16 1 19 18 20 9 19 5 -11 -15 -18 2
output:
23
result:
ok answer is '23'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
304 765 910 -240 338 -689 892 -518 663 447 796 716 -830 -465 835 426 88 -49 -810 -159 326 -345 -925 97 -371 496 921 693 526 785 -218 -939 119 935 -994 510 716 513 -18 -202 943 107 654 -940 629 592 529 618 403 -497 -538 -996 496 -499 80 768 714 -346 -477 883 -527 -116 -362 -462 389 818 -470 -124 -523...
output:
26103
result:
ok answer is '26103'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
383 551 205 -487 863 524 352 490 -44 -641 385 338 -915 -937 -588 -745 785 -574 -699 280 877 848 -418 -443 577 350 121 -420 -539 531 73 578 -836 238 -62 -792 -444 -558 -174 964 -531 3 -1000 -878 -879 -350 349 -957 345 -577 938 -865 -830 -574 760 496 58 697 868 830 372 -695 357 -582 423 -19 -536 -962 ...
output:
68
result:
ok answer is '68'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
293 -355 -542 -948 207 341 300 -15 48 170 -525 869 693 604 273 208 91 -130 846 -270 -621 470 831 -766 -997 -271 652 560 -411 -479 -790 -974 -4 -186 -565 -874 -653 993 -228 886 -189 982 -130 15 -644 282 432 658 264 441 297 -364 -19 170 -624 596 -184 -9 -426 -403 216 430 -168 -366 245 -755 -667 301 16...
output:
-483
result:
ok answer is '-483'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
211 22 858 192 -191 885 -30 310 931 -996 553 323 -551 524 770 158 406 -374 -136 -575 768 -873 772 10 -370 -830 674 697 -734 115 -183 609 -471 -172 875 219 574 352 -880 922 58 -129 349 -90 368 -154 701 715 711 -374 -102 970 -338 411 -286 -988 -470 4 83 -780 -595 831 -951 666 701 -215 -302 -380 643 -3...
output:
15031
result:
ok answer is '15031'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
203 43 665 -647 -672 395 614 774 758 -906 -117 695 372 -350 -613 -462 -820 -983 313 807 -926 -728 986 557 800 550 725 777 -692 -89 179 -239 286 620 254 241 956 -278 -152 200 700 -145 -596 -812 206 367 62 866 -237 382 -872 -783 461 299 541 474 429 -627 -620 -256 579 921 -328 309 860 -339 -234 822 578...
output:
4937
result:
ok answer is '4937'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
1533 698889648 -578827493 -262105442 909404291 413315551 58485223 -40086811 836333943 717569157 925214479 -838945545 -792185683 632330806 621194734 -507381703 -423877991 654299697 951418620 547944701 873444638 241721237 927202957 854398029 -423274017 -184376941 -902734053 -263563815 14928752 -547732...
output:
15440282162
result:
ok answer is '15440282162'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
1469 566891435 276813107 -269833434 798483192 156520609 -133927715 -824768342 467777943 719040677 -178306126 869292199 -20032178 447035639 -216440617 310099776 -762488256 973771530 529876893 667856043 438737869 971410281 16311549 257997890 -670244740 923408434 -63379580 -538519438 -645400242 -898960...
output:
16395493396
result:
ok answer is '16395493396'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
1985 929560645 -529651056 -475800686 812657562 -531442420 -665813585 477022342 -681178771 -172360956 435952834 737340151 470553112 -254078904 -868064285 388742274 -781943845 -180919708 -704870932 832988034 -127732657 458792030 -574973007 -364164993 -282902313 371345439 925852561 894889178 -932584458...
output:
22468865212
result:
ok answer is '22468865212'
Test #17:
score: 0
Accepted
time: 2ms
memory: 3808kb
input:
1427 147812685 518852015 384950377 146696734 383897841 -822036009 939313442 -751240855 515911498 776875835 -955250092 -608998648 702505581 -824766834 305241341 -39739151 -542042485 756504727 -181829956 403267534 645928558 50075039 988049368 -112200079 136403043 163248263 -851994349 879461710 -656335...
output:
302077185
result:
ok answer is '302077185'
Test #18:
score: 0
Accepted
time: 5ms
memory: 3672kb
input:
1450 470278047 773767752 990000080 -242116879 96288230 725638114 -61674317 -29899397 -32045069 802312805 -78083811 880664444 -346924816 -378420987 321633829 -842390774 -982647296 181780517 223588203 -662717337 525318314 -983342425 455920417 -69942256 651090836 910589323 -89662928 829196601 308210953...
output:
-18964546
result:
ok answer is '-18964546'
Test #19:
score: 0
Accepted
time: 9ms
memory: 3632kb
input:
1984 -568212242 575162077 -514770035 91825555 -645483562 -88733636 -880513486 429840581 835176245 -798940559 -511618216 -546468807 -325535970 -407573577 7011476 377714211 -599939502 119546053 49386463 570070856 -625133729 -466851340 724664580 7469856 893754968 635980938 -684162381 -750809832 6542638...
output:
-379863843
result:
ok answer is '-379863843'
Test #20:
score: 0
Accepted
time: 3ms
memory: 3680kb
input:
1116 601089292 579405688 -94377208 -98449065 423956902 -141443365 -229969880 -552546445 -780569369 646077425 129152676 -990833249 741168117 951542848 -83805503 -900209259 802951634 679032229 691376377 322278836 -231836349 71125826 451473271 418286372 -528321291 -243992311 702148477 694048272 -602910...
output:
677927233
result:
ok answer is '677927233'
Test #21:
score: 0
Accepted
time: 5ms
memory: 3672kb
input:
1514 -202658408 -599206472 -778289097 -196138201 -262772777 -180575986 376523861 -861306821 806965699 -657400270 -324321996 407114312 794163634 -842992469 414474658 -651202810 -170876621 -792083249 -489515314 -610070836 -391591906 -530125541 -727298001 -490140733 570832879 908935420 480988436 763222...
output:
-719559045
result:
ok answer is '-719559045'
Test #22:
score: 0
Accepted
time: 4ms
memory: 3612kb
input:
1046 902611092 -521004526 825136261 -267972239 -760856021 -199211210 -611730574 -723252373 963196809 -236215049 -322252031 -697293486 453441159 533780756 416726473 33130619 -333554520 838909737 333185492 22049119 -655398717 563046708 -797762479 -326683660 -724697806 -63396727 -437993103 193712632 64...
output:
-1433631367
result:
ok answer is '-1433631367'
Test #23:
score: 0
Accepted
time: 5ms
memory: 3608kb
input:
1251 671462714 809084646 650554870 -613452217 -610655284 306572566 -718515841 -610006678 -230999501 888582287 -723016106 -235311276 -450319766 -107187298 -593814272 23299531 -278309634 -709456072 -442874093 -330486263 -144651571 -256651233 27029982 -470161943 981840278 -816767304 386778821 -21407260...
output:
-316335426
result:
ok answer is '-316335426'
Test #24:
score: 0
Accepted
time: 512ms
memory: 10660kb
input:
160417 660077889 -939582949 -886464413 437646629 952348168 783950666 565300102 257525155 -822686209 408804377 178911152 501752515 -184917585 -844382657 558189506 953563805 -612679398 -946423368 558776016 -231391063 51211054 -10951300 -285189680 11073219 496729876 33597082 -5269524 565098299 -8045184...
output:
103988168563
result:
ok answer is '103988168563'
Test #25:
score: 0
Accepted
time: 1496ms
memory: 11876kb
input:
149214 -123307257 -9060121 482680900 -731658236 978447311 -755508336 -374381209 -745751752 267901499 -434787381 -434462026 -17666838 -523882604 745766564 -928934055 537950211 563994536 -691281753 -975342884 414828835 -930979194 679112672 -967791058 -509006243 -635387433 -722586576 951869311 -1057401...
output:
-596956450
result:
ok answer is '-596956450'
Test #26:
score: 0
Accepted
time: 166ms
memory: 12004kb
input:
160457 626164425 -347203178 -188784460 -379151721 -69888987 940361574 920272440 -154960301 73496704 -661047305 -82543478 449370570 374334367 -440589382 -205945147 95508005 -51343807 -443417332 903120719 -312685656 274910791 -571001460 519684605 -7281899 -369930422 -400568332 -679599051 -274086768 93...
output:
294181091302
result:
ok answer is '294181091302'
Test #27:
score: 0
Accepted
time: 142ms
memory: 10728kb
input:
130662 450575558 907732602 810840086 814791936 -31818830 -608596065 549793056 178460118 -898627080 -878197835 102299607 -662762849 -677512578 322975467 -752718743 736983830 998327592 344849947 666266794 -511728582 774921673 -487998686 -839518210 -335356149 357561187 -829450531 37908150 -145675599 68...
output:
246436161674
result:
ok answer is '246436161674'
Test #28:
score: 0
Accepted
time: 204ms
memory: 8684kb
input:
145716 581842073 -657041851 475633367 -835286083 -711240463 660733729 123168513 -939774663 356354571 -46572320 305636477 -377497258 17283698 646972308 -801531663 -670032569 -39167585 483296247 -215802948 363468518 -156359305 -168144601 -816568736 473764847 88526297 -857018179 -123062675 524795619 -2...
output:
37327981958
result:
ok answer is '37327981958'
Test #29:
score: 0
Accepted
time: 224ms
memory: 8828kb
input:
116518 720583823 -184139011 -755448128 -17671695 -548323741 -651686534 225029186 -427082835 275008003 -124645860 804189800 689637246 591822381 -290472440 394826756 428401640 -264826625 80144692 -678990238 -750221270 -597051965 641651056 415656098 -133379772 -441510592 241286437 573115932 938539023 2...
output:
74652604305
result:
ok answer is '74652604305'
Test #30:
score: 0
Accepted
time: 530ms
memory: 9892kb
input:
176320 564480641 369937753 -115510575 -507925896 412480991 -925592898 -187733529 -786761485 -788446224 -172570053 -580726148 -944525681 -161497140 -314448828 -917236979 -650206599 311681378 -290972141 -524909730 -532875466 -770064157 -327956309 -553905317 -152788441 -29650732 824610391 478704945 -33...
output:
79798680
result:
ok answer is '79798680'
Test #31:
score: 0
Accepted
time: 205ms
memory: 7220kb
input:
111752 591927769 -93001111 493449959 241587808 -920972953 232708751 805270921 -389078720 352630274 -461345975 29400879 439238049 263620079 -385018310 -375746838 858564983 656255273 425947784 527633074 -409879572 -209395214 410630980 255671969 912383796 989639908 487706267 -419724544 -306293822 94825...
output:
824048000
result:
ok answer is '824048000'
Test #32:
score: 0
Accepted
time: 710ms
memory: 10660kb
input:
159082 -588564835 93860242 624774258 975334432 304039131 -228764224 244567638 -866912663 -124512439 954727231 188601354 975963237 495366375 -765176159 -103262704 -682679156 552703638 560164168 456494384 -843126741 -61913904 -657367427 123754596 -638725203 -632279984 788031719 -73816904 -450922438 43...
output:
616387430
result:
ok answer is '616387430'
Test #33:
score: 0
Accepted
time: 166ms
memory: 12604kb
input:
168877 23538477 -378119702 -207967945 763218785 -782048705 666398144 -242508104 634516011 18259853 311047020 776883078 -284800278 702483498 -540968909 726455021 60114359 327612048 -479734815 -961359217 348601960 387779755 -462780565 -347148624 -258536808 388388466 -114926450 -941766926 337338350 411...
output:
36548853044
result:
ok answer is '36548853044'
Test #34:
score: 0
Accepted
time: 95ms
memory: 14920kb
input:
200000 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 1000000...
output:
200002000000000
result:
ok answer is '200002000000000'
Test #35:
score: 0
Accepted
time: 1347ms
memory: 15044kb
input:
200000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000...
output:
-3000000000
result:
ok answer is '-3000000000'
Test #36:
score: 0
Accepted
time: 467ms
memory: 9340kb
input:
107418 -866204338 -199823027 556329629 -663942557 794208395 314149573 -115957509 85478427 -95681960 702678921 -37054891 -875050493 454653991 -489684779 951356230 13192560 945918047 199622971 -548417554 912565822 637378465 752595450 88572428 -759543519 -263568891 969615137 545602189 239537065 -686770...
output:
99302228614
result:
ok answer is '99302228614'
Test #37:
score: 0
Accepted
time: 910ms
memory: 9376kb
input:
108824 -815219780 433099992 902424071 -246685750 648399259 435113931 720072738 -582485184 714767735 -127144440 -635142571 -661187086 774761963 971753825 -326178808 -389581860 814604795 180410518 -970829974 603734718 103827542 279190892 491070718 703515528 733708256 -770717236 306609232 -742984106 97...
output:
-143554733
result:
ok answer is '-143554733'
Test #38:
score: 0
Accepted
time: 1057ms
memory: 11424kb
input:
142009 -652652282 -931260609 708251017 -840449799 -970363854 -563389090 982524653 -709696489 627127774 -709294338 950132709 513551590 218639765 -748257116 -465804145 100105799 38180624 -77962986 298656117 -110091145 89195084 287907812 -605731148 714843979 -791940675 -506200291 -261653290 710065683 -...
output:
-825055658
result:
ok answer is '-825055658'
Test #39:
score: 0
Accepted
time: 26ms
memory: 6216kb
input:
68302 833092098 -208258598 576504504 -880001289 -518898139 -278456542 665722681 -372290376 124459338 -548505343 -83431344 527749835 -120955801 -794368937 -196006291 476360451 -345858457 -525134094 794531992 187849182 -87404211 690896256 135957471 104640128 812328386 691888454 720520824 926847944 325...
output:
213698706978
result:
ok answer is '213698706978'
Test #40:
score: 0
Accepted
time: 186ms
memory: 5680kb
input:
55626 -477098586 -693498876 -194404168 713244130 -754299575 -485559538 833679059 653551068 334662216 -571953436 313362739 501764575 42735145 -823771475 -870582371 -596568641 206980859 -999689869 -507542889 800281828 195320291 -586024741 -189354212 -672684885 569139556 677529257 -874300963 622035656 ...
output:
192722483
result:
ok answer is '192722483'
Test #41:
score: 0
Accepted
time: 214ms
memory: 9764kb
input:
125172 486257354 -653434368 888163032 597855850 -173174132 229074555 -317147008 -240513910 392795527 104638978 133845322 724941282 -977901608 362099995 82460662 -421990791 -609343027 225084575 65935692 -686154525 578253222 -98758631 980763602 762441734 -958793096 -598914002 -956967259 -106532156 554...
output:
148952570849
result:
ok answer is '148952570849'
Test #42:
score: 0
Accepted
time: 290ms
memory: 5944kb
input:
48096 877907250 979954944 -21555711 -105499314 810545081 664319638 927972045 482291732 221061686 -897139395 -613946695 56708348 499127788 551532165 -341068620 873860904 -665239528 -133032819 211617238 -818944266 488767467 -363165601 -610134351 -695867590 -971526015 -649659800 -791905220 27378670 678...
output:
-189869414
result:
ok answer is '-189869414'
Test #43:
score: 0
Accepted
time: 964ms
memory: 11208kb
input:
137985 -241508896 -406423179 263193043 237918325 -116798636 -739394097 -463867799 -578439460 -531726970 182366883 564307462 933720726 -606095221 -784294705 -316879055 -565130685 -850872137 -343412129 806484730 598355373 -243981128 868745710 537575210 -357994223 606336005 -676933461 -241395636 448346...
output:
-1199490161
result:
ok answer is '-1199490161'
Test #44:
score: 0
Accepted
time: 87ms
memory: 5020kb
input:
69516 -261534395 -549807665 -293471791 -800295917 -135728992 -481682555 356350173 456663206 -255399349 549227200 -209310826 -994119580 416391269 33217954 -656096359 561227399 -521438092 803251279 841197028 -66151158 140086138 -627741143 15351070 727612893 -621345215 878520108 -645531537 -738016912 -...
output:
71805563
result:
ok answer is '71805563'
Test #45:
score: 0
Accepted
time: 81ms
memory: 9960kb
input:
130688 675318505 -241225586 -449075632 501904179 319699446 800515669 -770572163 200908574 707766748 576642559 -437750539 -113185425 -691022934 928530106 996095706 676810854 -981897326 379253537 -11856745 -373448857 924970251 227946742 218250288 -830727054 -133447952 977155226 367642810 308904589 -38...
output:
80213371491
result:
ok answer is '80213371491'