CT59454

Brewer's Middle So Far Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the island market of Coralcove opens only for a perfect tally of ledgers. Brewer means to find out. Task: After each arrival, print the median of the stream so far — defined as the element at sorted position ceil(k/2) (1-based). Input format: First line: n. Second line: n integers. Output format: Print n medians space-separated. Constraints: 1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 2199 190100421 127678850 206419412 -201927366 539113993 752291202 -291382319 -287665907 -826995704 -544781554 -130274940 -683290546 -537316592 -569974840 824191437 -447033525 748914550 772297285 -464333948 -808355466 520548049 355802605 188569110 -778527057 -332843992 326486557 -835542682 -798859002 -504270670 -339272424 -106228163 691447975 -454210300 -330840729 -614922093 -423428061 -745042264 724617518 -230504530 798004168 948798874 -333783977 -14873529 758549600 622904402 194352685 -145458458 943235301 -105700906 -275246313 -769554125 59091051 -960189270 558798679 184757453 -514036683 -837689335 -982713320 226673568 517615178 -78345160 -647441655 80206127 490175341 484834999 406952298 927886687 69707886 -18051442 -28570653 638783711 599326439 -820336882 -922475795 226968723 484972888 2…
Output: 190100421 127678850 190100421 127678850 190100421 190100421 190100421 127678850 127678850 -201927366 -130274940 -201927366 -201927366 -287665907 -201927366 -287665907 -201927366 -201927366 -201927366 -287665907 -201927366 -201927366 -130274940 -201927366 -201927366 -201927366 -201927366 -287665907 -287665907 -291382319 -287665907 -287665907 -287665907 -291382319 -291382319 -330840729 -330840729 -330840729 -291382319 -291382319 -287665907 -291382319 -287665907 -287665907 -230504530 -230504530 -201927366 -201927366 -145458458 -201927366 -201927366 -201927366 -201927366 -201927366 -145458458 -201927366 -201927366 -230504530 -201927366 -201927366 -145458458 -201927366 -145458458 -145458458 -130274940 -130274940 -106228163 -106228163 -105700906 -105700906 -78345160 -78345160 -78345160 -10570090…

Example 2:

Input: 1790 14162429 -38708863 419100403 -683398509 -808378422 581733494 -947189071 940692437 -110707922 389255444 731020586 -43289413 -435561377 -177618475 -71091118 647178790 996876563 -36595696 -894359015 -884728723 -69854435 849702610 389857880 -535191606 -856059145 -252980187 23705731 90244362 -118944368 691123365 -484043277 86463412 -567619072 -121928316 -812146669 -973561270 545542395 -426997660 -395078999 310999806 -385606064 232311944 -664091172 318122079 996399018 -864744517 -690379523 -682892894 -456995967 -566121400 -383932765 -574638688 544328072 -722035943 503219882 888164728 729667252 -167269507 774201117 84327730 -685154582 -941156036 -606296283 -184283011 -884529754 -513795278 472886029 -460076460 -514618119 -990204920 -653730345 -762268653 -579137437 698080098 -261246848 -265311…
Output: 14162429 -38708863 14162429 -38708863 -38708863 -38708863 -38708863 -38708863 -38708863 -38708863 14162429 -38708863 -38708863 -43289413 -43289413 -43289413 -38708863 -38708863 -38708863 -43289413 -43289413 -43289413 -38708863 -43289413 -43289413 -69854435 -43289413 -43289413 -43289413 -43289413 -43289413 -43289413 -43289413 -69854435 -69854435 -71091118 -69854435 -71091118 -71091118 -71091118 -71091118 -71091118 -71091118 -71091118 -69854435 -71091118 -71091118 -110707922 -110707922 -118944368 -118944368 -121928316 -118944368 -121928316 -118944368 -118944368 -110707922 -118944368 -110707922 -110707922 -110707922 -118944368 -118944368 -121928316 -121928316 -167269507 -121928316 -167269507 -167269507 -177618475 -177618475 -184283011 -184283011 -184283011 -184283011 -252980187 -252980187 -25…

Example 3:

Input: 3534 -771263852 842175901 -640055811 242325948 754454740 420759697 81616999 -564771246 -205579598 -615390098 -845769051 -35703628 353258024 -365609231 -757702254 37173614 46432152 529070221 -882053090 535416092 794350913 -331362293 778071275 946908454 935158771 139950441 -325398405 171609774 968049096 805089536 562031991 -437665627 946714018 592698809 296306425 339603408 857817856 -130849232 -65011418 185944938 515275633 557059942 81940741 940965932 533762177 -945014152 941595239 3052855 -423195969 180205492 -686447806 -308660916 680969263 147589540 -660777463 -521698897 203832135 -548095545 725685485 107866306 115275057 801083899 213138139 771366260 155388689 -932994863 359408895 -509498485 -637870450 -48294515 -133972238 576903915 171351662 130947934 -232971106 654289332 -968535869 86250…
Output: -771263852 -771263852 -640055811 -640055811 242325948 242325948 242325948 81616999 81616999 -205579598 -205579598 -205579598 -35703628 -205579598 -205579598 -205579598 -35703628 -35703628 -35703628 -35703628 37173614 -35703628 37173614 37173614 46432152 46432152 46432152 46432152 81616999 81616999 139950441 81616999 139950441 139950441 171609774 171609774 242325948 171609774 171609774 171609774 185944938 185944938 185944938 185944938 242325948 185944938 242325948 185944938 185944938 180205492 180205492 171609774 180205492 171609774 171609774 147589540 171609774 147589540 171609774 147589540 147589540 147589540 171609774 171609774 171609774 155388689 171609774 155388689 155388689 147589540 147589540 147589540 155388689 147589540 147589540 147589540 147589540 147589540 155388689 147589540 15…

Constraints:

1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
Brewer's Middle So Far Ledger - MEDIUM Coding Problem | CodeTikki