QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#593191 | #9123. Kth Sum | dieselhuang | AC ✓ | 1150ms | 32588kb | C++14 | 1.3kb | 2024-09-27 12:28:23 | 2024-09-27 12:28:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k, B, D, cnt = 0, a[50010], b[50010], c[50010], d[50010], f[7100010];
struct Node{
int id, x;
bool operator <(const Node u) const{ return x > u.x; }
};
priority_queue <Node> q;
bool chk(ll x){
int i, j, p;
ll res = 0;
for(i = 1; i <= B; i++){
for(j = 1, p = n; j <= n; j++){
while(p > 0 && (ll)a[i] + b[j] + c[p] > x) p--;
res += p;
}
}
for(j = cnt; i <= n; i++){
while(j > 0 && (ll)a[i] + f[j] > x) j--;
res += j;
}
return res >= k;
}
int main()
{
int i;
ll l, r, md;
scanf("%d%d", &n, &k);
B = min(n, max((int)sqrt(k / n), 1)); D = k / B;
for(i = 1; i <= n; i++) scanf("%d", &a[i]);
for(i = 1; i <= n; i++) scanf("%d", &b[i]);
for(i = 1; i <= n; i++) scanf("%d", &c[i]);
sort(a + 1, a + n + 1);
sort(b + 1, b + n + 1);
sort(c + 1, c + n + 1);
if(B < n){
for(i = 1; i <= n; i++) d[i] = 1, q.push({i, b[i] + c[1]});
while(cnt < D && q.size() > 0){
i = q.top().id; q.pop();
f[++cnt] = b[i] + c[d[i]++];
if(d[i] <= n) q.push({i, b[i] + c[d[i]]});
}
}
l = (ll)a[1] + b[1] + c[1]; r = (ll)a[n] + b[n] + c[n];
while(l < r){
md = l + r >> 1;
if(chk(md)) r = md;
else l = md + 1;
}
printf("%lld", l);
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
input:
2 4 1 2 3 4 5 6
output:
10
result:
ok "10"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
10 40 11 9 13 12 15 11 11 2 11 17 3 1 10 2 12 18 9 11 11 15 14 9 4 14 16 9 20 2 1 18
output:
14
result:
ok "14"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
1 1 1000000000 1000000000 1000000000
output:
3000000000
result:
ok "3000000000"
Test #4:
score: 0
Accepted
time: 14ms
memory: 6064kb
input:
314 12491830 429392519 92131736 9460149 448874040 5326166 804308891 571581523 580832602 110825817 11150177 47845585 886171410 888601860 633656718 879205016 333690452 739013504 118317331 8289119 502971381 486014573 167383690 96016893 556946780 634198668 389358242 984894049 735281439 58642904 22106451...
output:
1346801336
result:
ok "1346801336"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
34 34490 133495256 283197838 857697935 858259368 959152648 301897236 990604260 865643006 704101978 322295867 324109158 258113372 423370893 16000407 224364583 353708691 265955784 183826167 813127458 476308169 634865805 973017138 197716378 674895784 956141489 277068847 534893183 817797721 662940992 82...
output:
2149314674
result:
ok "2149314674"
Test #6:
score: 0
Accepted
time: 4ms
memory: 6020kb
input:
162 3892887 763969065 810700429 42372207 636240914 502913712 840954780 778223217 445420701 2410846 338474264 231776510 588586138 368205344 103376804 569524150 783792347 87865355 617931224 986562016 523273886 488749745 483683293 299415863 792844787 204455380 164779452 748455830 195281294 930802591 80...
output:
2182951602
result:
ok "2182951602"
Test #7:
score: 0
Accepted
time: 2ms
memory: 5956kb
input:
86 413467 763039094 633170311 595642701 709189753 825336413 674979614 902278662 98827324 300719716 354652661 803007374 960528102 608007086 822156983 251120206 213876002 319840344 52036279 86367645 865206894 637600977 362945669 769711568 205761081 157801980 52490057 298454964 572764868 125035261 4872...
output:
1675510101
result:
ok "1675510101"
Test #8:
score: 0
Accepted
time: 9ms
memory: 5952kb
input:
214 7057935 98545611 529269121 443880485 487171300 369097477 582633376 321301399 678605020 893995877 2234839 79270945 291000867 847808829 204500671 596279774 233894241 478186405 117545115 891205983 838543682 491484917 873611825 871411053 323710085 406115873 645233371 143421391 950248441 24300640 758...
output:
1763767750
result:
ok "1763767750"
Test #9:
score: 0
Accepted
time: 452ms
memory: 16376kb
input:
9429 823330096 710308717 885443360 151359742 257927627 89698847 133943367 458101850 441715448 448225213 867533556 948805555 168922334 660173729 242187286 990107147 920584508 611308123 525304427 558566303 443722397 295118124 112161359 258379911 198998755 698515100 523982637 41263636 383698580 8552056...
output:
185843818
result:
ok "185843818"
Test #10:
score: 0
Accepted
time: 401ms
memory: 15108kb
input:
10149 691846236 340782526 117978658 704630235 330876466 338492620 967968202 245720807 95122072 746534082 178679244 520036419 909460517 605008179 624530975 335266714 940602747 138250403 254376775 953339225 417059185 149002064 622827516 360079396 316947758 946828992 411693242 959858992 761182154 75447...
output:
160042939
result:
ok "160042939"
Test #11:
score: 0
Accepted
time: 268ms
memory: 11624kb
input:
26277 120170888 971256336 940448541 552868020 445294502 955882613 875621964 664743544 674899768 413439170 194857641 796299991 871337063 844809922 711907373 680426281 739282622 1629172 393514539 758177562 464024901 297853296 133493671 461778881 66300541 195142884 4436555 804825418 138665726 22332656 ...
output:
34606249
result:
ok "34606249"
Test #12:
score: 0
Accepted
time: 413ms
memory: 15012kb
input:
9701 693719733 675359072 836547350 106138512 518243340 204676385 709646799 83766281 959710172 711748039 842439820 367530854 906842537 84611664 725654842 656989629 169366277 823538745 459023375 857983192 805957909 151737236 12756046 932074585 184249545 148489484 597179869 354824553 516149300 92159803...
output:
163052076
result:
ok "163052076"
Test #13:
score: 0
Accepted
time: 539ms
memory: 20092kb
input:
43125 267268577 10865589 364049940 290812785 296224887 822066378 248704341 207821727 539487867 10056907 153585508 980230915 278784499 955817187 813031240 2149196 189384516 350481024 893128432 31417749 779294698 300588468 818389495 328741361 597165840 765399596 484890474 199790980 598665582 115830706...
output:
27436842
result:
ok "27436842"
Test #14:
score: 0
Accepted
time: 730ms
memory: 22976kb
input:
26549 840817422 9935618 186519822 139050570 369173726 70860150 451325395 995440684 192894490 603333068 169763905 551461778 609257266 195618929 826778709 347308764 619468172 582456013 958637268 836256088 826260414 449439700 329055650 799037066 420147551 13713488 77633787 118386334 976149156 383692305...
output:
63457689
result:
ok "63457689"
Test #15:
score: 0
Accepted
time: 870ms
memory: 27204kb
input:
42677 709333562 640409427 82618632 987288355 147155272 688250143 990382938 414463421 772672187 901641938 185942303 122692641 981199229 435420671 914155107 323872111 49551827 404365585 392742323 936061718 168193421 598290933 839721806 900736551 833063847 967060089 965344393 963352762 58665437 9879903...
output:
38001103
result:
ok "38001103"
Test #16:
score: 0
Accepted
time: 412ms
memory: 17860kb
input:
26101 282882406 344512164 905088515 835526140 556540600 937043916 487971283 833486158 57482590 494918098 202120700 30359993 943075775 380255122 1531503 374064387 774602775 636340574 458251160 740900055 141530209 452174873 13951473 2436035 951012850 215373980 853054998 808319188 804745231 887255771 4...
output:
44566864
result:
ok "44566864"
Test #17:
score: 0
Accepted
time: 400ms
memory: 17716kb
input:
9525 711207059 974985974 432591104 388796632 334522147 480804980 27028826 326137823 637260286 793226967 218299097 601590857 978581249 915024156 15278973 55660443 499653722 794686634 892356216 545738393 188495925 306058813 524617629 472731740 68961852 537316801 445798311 726914543 182228803 450084661...
output:
163907546
result:
ok "163907546"
Test #18:
score: 0
Accepted
time: 412ms
memory: 15128kb
input:
25653 284755903 605459782 328689914 237034417 407470985 803227681 229649880 745160560 922070690 91535835 529444787 582887137 645490503 154825898 102655370 400820010 929737378 321628914 326461271 645544023 530428934 749877337 35283784 574431225 818314637 490663401 669945405 276913678 264745085 349350...
output:
48615466
result:
ok "48615466"
Test #19:
score: 0
Accepted
time: 1082ms
memory: 32584kb
input:
49204 940175312 917595988 720224180 998292043 66981215 174071529 800014332 639589470 671194515 859253536 723916933 513329035 820269479 768182087 145685145 469605497 171042074 115006523 595855035 698778069 679440704 104221675 761971738 715710220 177487218 689202604 363639740 97633225 327083012 946735...
output:
35690494
result:
ok "35690494"
Test #20:
score: 0
Accepted
time: 1070ms
memory: 32372kb
input:
46425 946401698 548069796 542694061 846529827 139930053 791461522 2635386 132241135 956004919 157562404 740095331 715963680 192211441 713016538 233061543 446168845 896093022 641948804 29960090 798583699 652777492 958105616 272637894 817409705 295436221 937516496 956383054 311195872 409599294 8460011...
output:
37816893
result:
ok "37816893"
Test #21:
score: 0
Accepted
time: 1092ms
memory: 32224kb
input:
45804 962693577 547139825 70196651 694767612 917911601 40255294 541692929 551263872 535782614 455871273 387677508 697259960 227716915 247785571 615405232 791328413 326176677 873923793 95468927 603422037 699743209 811989556 78271341 919109190 413385225 554426607 844093659 861195007 787082868 74526650...
output:
37594987
result:
ok "37594987"
Test #22:
score: 0
Accepted
time: 1051ms
memory: 31676kb
input:
43025 989976325 587679051 966295462 248038104 327296928 657645287 744313983 970286610 894221947 49147434 403855905 268490823 189593461 487587314 334185410 767891760 51227624 400866072 529573983 408260375 41676216 960840788 588937497 389404894 531334228 507773208 363208044 706161434 869599150 1312810...
output:
42569689
result:
ok "42569689"
Test #23:
score: 0
Accepted
time: 953ms
memory: 30248kb
input:
40246 901235456 586749079 788765344 801308598 105278474 906439060 283371525 757905566 473999642 347456303 715001595 544754395 930131644 432421765 421561807 113051327 776278572 927808353 300115527 508066004 15013004 109692019 468199873 491104379 575654303 756087100 955951358 624756788 247082723 20736...
output:
43371155
result:
ok "43371155"
Test #24:
score: 0
Accepted
time: 1063ms
memory: 32504kb
input:
47468 912494588 217222888 316267934 280950162 178227313 523829052 117396360 881961012 758810046 645765172 26147283 747389039 892008190 672223507 435309277 458210895 206362227 454750633 734220584 312904342 61978720 258543251 978866029 961400084 398636015 709433700 843661963 469723215 624566297 106626...
output:
37262730
result:
ok "37262730"
Test #25:
score: 0
Accepted
time: 1062ms
memory: 31868kb
input:
46847 918720974 552729406 507334036 129187947 956208861 67590116 320017414 300983748 338587741 239041332 42325680 318619902 927513665 912025250 522685674 139806950 931413175 613096693 799729420 486338900 403911728 743830973 489532184 63099568 811552310 31376520 436405276 19722350 707082578 79520458 ...
output:
37400312
result:
ok "37400312"
Test #26:
score: 0
Accepted
time: 998ms
memory: 30264kb
input:
41910 935012853 551799434 739869334 682458440 734190407 21416597 154042248 88602705 623398146 537350201 58504077 299916182 594422919 151826991 905029364 484966518 361496830 140038973 233834475 586144530 377248517 892682205 663761851 164799053 929501313 279690412 29148589 569721485 748129663 97878583...
output:
42423220
result:
ok "42423220"
Test #27:
score: 0
Accepted
time: 977ms
memory: 32444kb
input:
41289 941239238 182273243 267371924 530696225 143575734 933773882 61696010 507625442 276804769 835659070 369649767 502550826 261332173 391628734 623809541 830126086 86547777 666981254 667939532 685950160 424214233 746566145 174428007 635094758 47450316 528004304 916859195 488316840 125613236 1730185...
output:
43104373
result:
ok "43104373"
Test #28:
score: 0
Accepted
time: 995ms
memory: 29732kb
input:
40668 973554733 181343272 458438026 378934009 216524573 182567654 895720846 631680888 856582465 133967939 385828164 73781689 296837647 336463184 6153230 806689434 811598725 898956243 733448368 785755789 766147241 895417377 980061455 736794243 460366611 481350905 509602508 333283266 208129518 4408801...
output:
45102815
result:
ok "45102815"
Test #29:
score: 0
Accepted
time: 1150ms
memory: 32560kb
input:
50000 1000000000 440077270 328816170 274329186 506440663 53022490 728310039 424691124 582918053 582285373 175213225 917409061 552999000 202450116 768602239 402613373 792406902 350953524 358473252 95288654 748872361 666113891 68646973 438219049 788529116 845510470 575031047 796486556 597554337 508570...
output:
35145696
result:
ok "35145696"
Test #30:
score: 0
Accepted
time: 1139ms
memory: 32552kb
input:
50000 1000000000 617334451 51366151 821626678 750310709 55891135 16875985 997493741 841084124 633442543 778335639 703656788 379329969 867490664 165624569 399078963 45624892 29280415 761619113 192192761 611189472 353588758 965104075 889765067 102194189 166544014 986338271 203914326 397169555 74039474...
output:
36344214
result:
ok "36344214"
Test #31:
score: 0
Accepted
time: 1123ms
memory: 32448kb
input:
50000 1000000000 499624340 437479645 663891461 994180755 353727071 674038152 865263649 25621265 684599713 455086980 194937223 910693648 237563919 562646901 764140773 3875592 412640015 459732265 920500649 178539291 967434699 492964956 46343792 415859263 824014048 102678203 537713169 606850191 8985897...
output:
35638933
result:
ok "35638933"
Test #32:
score: 0
Accepted
time: 1129ms
memory: 32564kb
input:
50000 1000000000 971848814 160029627 874752465 238050801 282966787 962604100 143098973 578754628 30724174 468274810 54813878 737024617 902604466 886040305 834235291 625689803 795999615 526441637 722437464 40856402 949876858 94454765 497889810 434557045 555113009 808952719 871512012 111498117 1304135...
output:
37428373
result:
ok "37428373"
Test #33:
score: 0
Accepted
time: 1129ms
memory: 32484kb
input:
50000 1000000000 854138703 177546900 717017248 481920847 285835431 251170046 10868881 131887990 81881344 145026151 546094315 899792075 567645013 578029927 904329809 583940503 474326506 224554788 524374279 903173514 563722797 285879157 318032047 748222119 581179262 925292651 573907074 279709555 36223...
output:
36925907
result:
ok "36925907"
Test #34:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
1 1 0 0 0
output:
0
result:
ok "0"
Test #35:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
2 8 0 1000000000 0 1000000000 0 1000000000
output:
3000000000
result:
ok "3000000000"
Test #36:
score: 0
Accepted
time: 1ms
memory: 5944kb
input:
2 1 0 1000000000 0 1000000000 0 1000000000
output:
0
result:
ok "0"
Test #37:
score: 0
Accepted
time: 8ms
memory: 4704kb
input:
50000 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
0
result:
ok "0"
Test #38:
score: 0
Accepted
time: 13ms
memory: 4688kb
input:
50000 1 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:
3000000000
result:
ok "3000000000"
Test #39:
score: 0
Accepted
time: 11ms
memory: 4748kb
input:
50000 1 0 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 1000...
output:
0
result:
ok "0"
Test #40:
score: 0
Accepted
time: 714ms
memory: 32536kb
input:
50000 1000000000 0 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:
2000000000
result:
ok "2000000000"
Test #41:
score: 0
Accepted
time: 1081ms
memory: 32368kb
input:
50000 1000000000 914566074 976733237 957735197 980073128 983391955 982553567 949555427 928162055 909041946 919953616 984720422 931140081 914928491 932902760 918548261 939896009 950462164 918391737 903899874 926706203 982751367 980942107 992863395 990798465 936935158 920621823 952849420 973650860 954...
output:
2703489304
result:
ok "2703489304"
Test #42:
score: 0
Accepted
time: 1086ms
memory: 32588kb
input:
50000 1000000000 989419814 921240854 996411918 978035952 926583127 971181942 911672373 994189028 969461911 977681379 989852038 941991617 972821476 957949286 904674098 953059082 910809674 974552057 952388233 925457795 907389243 999660232 914611010 956021145 972587654 962780927 904760250 931442092 904...
output:
2703754827
result:
ok "2703754827"
Test #43:
score: 0
Accepted
time: 1095ms
memory: 32348kb
input:
50000 1000000000 959240806 965748473 946079505 970966028 964741552 938753955 973789320 944192386 934914622 909320032 973927292 947810406 930714460 993061305 916889044 961189409 976189932 930712377 974787483 929242134 963148975 908312861 925367758 921243825 918305643 999907284 956671081 915322433 971...
output:
2703617545
result:
ok "2703617545"
Test #44:
score: 0
Accepted
time: 1095ms
memory: 32392kb
input:
50000 1000000000 929061798 994232477 984756225 968928851 902899976 927382330 940939013 994195745 900367333 972080542 979058908 953629196 993640192 944196939 903014881 974352482 941570189 965816336 902219479 927993726 987786851 927030986 952148121 991499253 958990886 937033641 987525550 904235521 921...
output:
2703488841
result:
ok "2703488841"
Test #45:
score: 0
Accepted
time: 1089ms
memory: 32508kb
input:
50000 1000000000 903915537 938740094 939456559 971924422 941058402 916010705 908088706 970288212 939730936 929808304 984190525 959447985 946500428 979308959 994173466 977450062 922974061 927009403 929651476 926745318 933481088 961772726 978928484 956721933 999676129 974159998 939436380 983083116 972...
output:
2703555640
result:
ok "2703555640"
Extra Test:
score: 0
Extra Test Passed