CT57269

Surveyor's Middle So Far Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the basalt cliffs of Obsidian Shore. Surveyor spreads the registers records across the table and picks up a sharp pencil. 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: 1164 -399398710 402721852 235839234 206263158 -470612269 -736279431 -396334085 176593303 -1649169 293655824 364760844 230919900 -904818906 -806835662 368806128 -474361543 -579369436 810515080 625023493 231740047 -638251564 792953446 548812057 -750589168 -680383285 852717137 155355848 118174225 402389719 -502468231 894657674 145748277 589965278 -664074920 -320514589 545766354 151497253 -135214965 567727082 -478703093 647979822 561189299 408750160 -487767276 399638785 118508525 -447236685 693449961 -39211929 960929192 -382003897 392888942 174408648 255414465 62775838 -507064613 580460520 -284684621 200220497 184181621 630835120 904254994 -776449131 -657823469 5067522 -816371042 479382562 8425751 632060047 -291022420 -677771006 70761779 737675833 -89475463 804417786 -309234010 186483349 -5035…
Output: -399398710 -399398710 235839234 206263158 206263158 -399398710 -396334085 -396334085 -1649169 -1649169 176593303 176593303 176593303 -1649169 176593303 -1649169 -1649169 -1649169 176593303 176593303 176593303 176593303 206263158 176593303 176593303 176593303 176593303 155355848 176593303 155355848 176593303 155355848 176593303 155355848 155355848 155355848 155355848 151497253 155355848 151497253 155355848 155355848 176593303 155355848 176593303 155355848 155355848 155355848 155355848 155355848 155355848 155355848 174408648 174408648 174408648 155355848 174408648 155355848 174408648 174408648 176593303 176593303 176593303 174408648 174408648 155355848 174408648 155355848 174408648 155355848 155355848 151497253 155355848 151497253 155355848 151497253 155355848 151497253 155355848 151497253 1…

Example 2:

Input: 269 -576975059 -350112490 454776583 541271690 503251962 205364881 -238967431 -205937549 667482716 536373189 -504463936 -401394101 322872209 822522288 -190752388 -553217700 -324489872 918632596 -233902770 -847464084 900587945 -469428559 395989446 771740305 700524498 56051989 -934926339 -155975971 788099977 -532018458 327853775 467798445 -355972697 958015419 722626967 617999715 -455338556 -42752111 240314300 -188248274 190302534 347008718 119080930 -322042632 -252855776 -806768287 -251269596 -78967467 -386423871 -566156805 5054962 -920556780 -872748079 -912386648 -562461701 -185427946 666257564 921219018 701844734 861643541 238550090 -963966793 -650108563 -528137678 730647837 659360337 -363644854 980318214 -639457814 -404238541 -718103109 -685507913 206372428 869397615 658847727 -287503747 6…
Output: -576975059 -576975059 -350112490 -350112490 454776583 205364881 205364881 -205937549 205364881 205364881 205364881 -205937549 205364881 205364881 205364881 -190752388 -190752388 -190752388 -190752388 -205937549 -190752388 -205937549 -190752388 -190752388 205364881 56051989 56051989 -155975971 56051989 -155975971 56051989 56051989 56051989 56051989 205364881 205364881 205364881 56051989 205364881 56051989 190302534 190302534 190302534 119080930 119080930 56051989 56051989 -42752111 -42752111 -78967467 -42752111 -78967467 -78967467 -155975971 -155975971 -185427946 -155975971 -155975971 -78967467 -78967467 -42752111 -78967467 -78967467 -155975971 -78967467 -78967467 -78967467 -78967467 -78967467 -155975971 -155975971 -185427946 -155975971 -155975971 -78967467 -155975971 -78967467 -78967467 -7…

Example 3:

Input: 514 -264426881 495378091 277751422 -814939058 479421915 -253676842 201461352 -748879630 -698619213 -901507795 -302776573 32369065 407660344 -953391570 488877733 621394140 -309434108 599904632 448822900 470023162 396344870 -698845989 339092754 -777937767 930539720 -189842256 131314456 344685565 454587694 -867516403 123903513 -311701020 55181540 514094842 39165264 610010553 -584769824 623144732 808229286 -143837947 871500892 -262349403 312768518 352840546 506834905 -488724173 -232879760 48868986 -763615341 35088928 -240056556 -241492289 993992063 -748246116 -608481404 -357338089 -320339703 -877346213 722475139 -599465308 558214011 784881959 -522013385 710638562 -23731663 993859944 264700582 -650232412 455482977 -259262012 -738664808 -534450379 -438593186 -54334545 598583036 502677122 2235729…
Output: -264426881 -264426881 277751422 -264426881 277751422 -253676842 201461352 -253676842 -253676842 -264426881 -264426881 -264426881 -253676842 -264426881 -253676842 -253676842 -253676842 -253676842 32369065 32369065 201461352 32369065 201461352 32369065 201461352 32369065 131314456 131314456 201461352 131314456 131314456 123903513 123903513 123903513 123903513 123903513 123903513 123903513 131314456 123903513 131314456 123903513 131314456 131314456 201461352 131314456 131314456 123903513 123903513 55181540 55181540 48868986 55181540 48868986 48868986 39165264 39165264 35088928 39165264 35088928 39165264 39165264 39165264 39165264 39165264 39165264 48868986 39165264 48868986 39165264 39165264 35088928 35088928 32369065 35088928 35088928 39165264 35088928 39165264 39165264 48868986 48868986 551…

Constraints:

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

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