CT65069

Nina's beacons Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Nina the ledger master watches over the archive halls of Scrollkeep's stores of beacons. A careful computation stands between order and chaos. 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: 2306 666290615 -400733125 -624655332 -35594257 -922363169 -421356127 265021582 213193305 862236873 -735780395 -103464372 -165011947 231984924 52926909 243770614 -891594132 306869281 -351272156 865004678 794789649 -410885331 151836293 177697771 -664858356 -31045971 -847835060 287962056 -758874940 500310722 576780190 992883691 -826806512 261544300 800994408 -792089875 984968702 -209172530 -323444871 -697346645 563822224 -967589617 -425995195 830301457 998193820 -549502606 382444650 56812514 -764959085 614106071 438965532 -993985063 853477383 -583357063 -104957978 -51324805 -812947717 -895590668 746339005 868957334 -562777425 -986122472 -564904252 -617271555 521681740 -851816634 -662192407 -753971708 -70263879 -993340616 306601087 83796371 -827202012 -256295099 -281880324 439092944 -109529268…
Output: 666290615 -400733125 -400733125 -400733125 -400733125 -421356127 -400733125 -400733125 -35594257 -400733125 -103464372 -165011947 -103464372 -103464372 -35594257 -103464372 -35594257 -103464372 -35594257 -35594257 -35594257 -35594257 52926909 -35594257 -31045971 -35594257 -31045971 -35594257 -31045971 -31045971 52926909 -31045971 52926909 52926909 52926909 52926909 52926909 -31045971 -31045971 -31045971 -31045971 -35594257 -31045971 -31045971 -31045971 -31045971 52926909 -31045971 52926909 52926909 52926909 52926909 52926909 -31045971 -31045971 -35594257 -35594257 -35594257 -31045971 -35594257 -35594257 -51324805 -51324805 -51324805 -51324805 -103464372 -103464372 -103464372 -103464372 -103464372 -70263879 -103464372 -103464372 -104957978 -103464372 -104957978 -104957978 -104957978 -103464…

Example 2:

Input: 2410 -937968215 -204339682 -16327457 -622117640 954701870 -734147230 -562790564 -214016874 -42514694 -888425215 -349978878 161499956 -159440980 -907765793 -728485597 305975939 -649094963 -405559630 -780608387 470344489 280548712 427386785 -577840776 68931186 -410925081 -731126008 657472699 -907096153 629484238 -68996833 -618189084 -290790699 715379026 876763839 552435696 -237936278 149099351 836806115 681113770 -51184053 923464498 -952471764 -247966187 800515238 -454778341 -682655507 227060501 18580068 936790312 325524808 -831181711 -522135630 985261138 61769298 -750383855 -86909 821286693 -482510273 -52330261 -247805247 -617093821 815800055 -236484220 250285682 -706526182 -527733635 419073317 -293038612 822801251 -676559262 561452913 2397713 -924776381 823092075 -774948171 882139023 -9108…
Output: -937968215 -937968215 -204339682 -622117640 -204339682 -622117640 -562790564 -562790564 -214016874 -562790564 -349978878 -349978878 -214016874 -349978878 -349978878 -349978878 -349978878 -405559630 -405559630 -405559630 -349978878 -349978878 -349978878 -349978878 -349978878 -405559630 -349978878 -405559630 -349978878 -349978878 -349978878 -349978878 -290790699 -290790699 -214016874 -237936278 -214016874 -214016874 -204339682 -204339682 -159440980 -204339682 -204339682 -204339682 -204339682 -214016874 -204339682 -204339682 -159440980 -159440980 -159440980 -204339682 -159440980 -159440980 -159440980 -159440980 -68996833 -159440980 -68996833 -159440980 -159440980 -159440980 -159440980 -159440980 -159440980 -204339682 -159440980 -204339682 -159440980 -204339682 -159440980 -159440980 -159440980…

Example 3:

Input: 2719 -243597823 939953557 689352673 12199514 -696969778 451567942 523732646 436421135 -511657295 154053631 -652859828 964516512 804063543 -499975748 462717163 -614829198 -920041583 -112459912 -101038071 -558383402 -808467323 952937554 980214799 -332169970 -228235797 -298462591 -261242765 836652667 -959633026 -119233153 -260200915 -474663497 643431098 357255523 -152000075 47397658 -132128054 434817427 -644300314 49853850 -369386791 -751475792 -91930799 38151058 231590345 -733285011 -999648237 515646035 275832633 -520486358 751279336 825723182 473130543 -468243002 -421220654 -775899605 672007091 409062892 458600977 -553805875 -342750926 -442106159 -577833453 502719098 -7698888 -717222213 -687028739 213730402 987353640 798148373 -866446054 -452537237 -198894538 465290812 -220644321 -314884009…
Output: -243597823 -243597823 689352673 12199514 12199514 12199514 451567942 436421135 436421135 154053631 154053631 154053631 436421135 154053631 436421135 154053631 154053631 12199514 12199514 -101038071 -101038071 -101038071 12199514 -101038071 -101038071 -112459912 -112459912 -112459912 -112459912 -119233153 -119233153 -228235797 -119233153 -119233153 -119233153 -119233153 -119233153 -119233153 -119233153 -119233153 -119233153 -132128054 -119233153 -119233153 -112459912 -119233153 -119233153 -119233153 -112459912 -119233153 -112459912 -112459912 -101038071 -112459912 -112459912 -119233153 -112459912 -112459912 -101038071 -112459912 -112459912 -119233153 -119233153 -119233153 -112459912 -119233153 -119233153 -119233153 -112459912 -112459912 -112459912 -119233153 -119233153 -119233153 -119233153…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nina's beacons Reckoning - MEDIUM Coding Problem | CodeTikki