CT61276

The Mossy ledgers of Sara

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the pine barrens of Needlepoint, Sara studies rows of ledgers entries. One clean number will settle the guild's oldest argument. 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: 1328 120964059 55433735 -864861569 861427110 953869259 437421421 595066806 -55245631 -433463518 587175784 904496762 856165149 587593736 -84609322 -377262086 756930187 -899288748 -567747895 49051168 197382270 114717618 -611266109 -326654805 -787243088 -103615356 860725111 -745057513 -60324871 -288669158 414255606 -719038266 -916658866 -308625767 -32165947 -583148160 -873885999 -413531119 -993125257 331135820 -445449857 -814865888 -320440829 -370676055 -737229694 -191978113 -990641818 -639684419 -795424877 -882033559 -220767099 -808606192 -387453775 -673773688 -520590918 -295718265 -150934767 338726019 -757501096 637208259 -191139477 -308928200 410662406 -223337464 762611717 9405220 150351340 -483871694 -587505690 865522087 448408842 -126067947 327456814 -522284350 -889750207 -366992 -915530…
Output: 120964059 55433735 55433735 55433735 120964059 120964059 437421421 120964059 120964059 120964059 437421421 437421421 587175784 437421421 437421421 437421421 437421421 120964059 120964059 120964059 120964059 114717618 114717618 55433735 55433735 55433735 55433735 49051168 49051168 49051168 49051168 -55245631 -55245631 -55245631 -55245631 -60324871 -60324871 -84609322 -60324871 -84609322 -84609322 -103615356 -103615356 -288669158 -191978113 -288669158 -288669158 -308625767 -308625767 -308625767 -308625767 -320440829 -320440829 -326654805 -320440829 -320440829 -308625767 -320440829 -308625767 -308625767 -308625767 -308625767 -295718265 -295718265 -288669158 -288669158 -288669158 -295718265 -288669158 -288669158 -223337464 -223337464 -223337464 -288669158 -223337464 -288669158 -223337464 -2886…

Example 2:

Input: 3898 -854905276 -263402114 129254885 -798477823 -262558885 732815304 910775663 -987634228 -199917493 976869744 190854631 517682144 941908554 341096422 40609468 878529021 602258389 43045594 -958487076 -352951876 505631780 -933460603 -202519740 658908239 67847092 -982046858 96350081 -468389358 -502867673 -450345749 -170364743 -396849378 -252475179 -840859068 -473851232 193792556 999136108 -864228790 65117645 461470126 637826489 -344321926 -660968116 -489765642 303129989 -443293235 -578000898 -868936918 -468308109 366994217 271291497 -94400821 -591470828 844413437 605732643 714080515 -684862591 937746569 491590295 201547250 869402564 779742154 720391012 150532459 169888340 996207852 -205816961 522832315 915086595 -878102793 -202463696 -400596004 783744146 477104990 -163979456 10956611 6897347…
Output: -854905276 -854905276 -263402114 -798477823 -263402114 -263402114 -262558885 -263402114 -262558885 -262558885 -199917493 -199917493 129254885 129254885 129254885 129254885 190854631 129254885 129254885 43045594 129254885 43045594 43045594 43045594 67847092 43045594 67847092 43045594 43045594 40609468 40609468 -170364743 -170364743 -199917493 -199917493 -199917493 -170364743 -199917493 -170364743 -170364743 40609468 -170364743 -170364743 -199917493 -170364743 -199917493 -199917493 -202519740 -202519740 -202519740 -199917493 -199917493 -199917493 -199917493 -170364743 -170364743 -170364743 -170364743 -94400821 -94400821 40609468 40609468 43045594 43045594 65117645 65117645 65117645 65117645 67847092 65117645 65117645 43045594 65117645 65117645 65117645 43045594 65117645 65117645 65117645 430…

Example 3:

Input: 1476 -357805076 645410375 -806488407 -870219634 -957499991 -729399591 683369490 310277318 182401556 26475750 -977364368 788559459 -249716884 983236059 -403611000 716252909 -918282921 -991903678 -504171792 353005847 -687002786 63279006 -607400924 -894808053 -801019305 817841798 752019050 628854945 45761156 47811483 573858978 -454989825 -467812682 958113290 -723295181 910183576 634045858 981512246 -588041858 -306819075 -219473259 -656599014 -124329320 -822386931 500072513 -996778846 -466597112 915027896 -346908286 -372581619 294561045 -654425230 -46738785 746316368 255090497 -834332420 -644327757 -231645273 544122150 841908899 -559153824 578717159 -432252929 -676504809 -961854399 -272753694 405091914 -881159829 -294466181 872736851 -931715294 420991778 -148945352 -846872563 -230757976 306798…
Output: -357805076 -357805076 -357805076 -806488407 -806488407 -806488407 -729399591 -729399591 -357805076 -357805076 -357805076 -357805076 -249716884 -249716884 -249716884 -249716884 -249716884 -357805076 -357805076 -357805076 -357805076 -357805076 -357805076 -403611000 -403611000 -403611000 -357805076 -357805076 -249716884 -249716884 26475750 -249716884 -249716884 -249716884 -249716884 -249716884 26475750 26475750 26475750 -249716884 -219473259 -249716884 -219473259 -249716884 -219473259 -249716884 -249716884 -249716884 -249716884 -306819075 -249716884 -306819075 -249716884 -249716884 -219473259 -249716884 -249716884 -249716884 -231645273 -231645273 -231645273 -231645273 -231645273 -249716884 -249716884 -272753694 -249716884 -272753694 -272753694 -272753694 -272753694 -272753694 -249716884 -2727…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Mossy ledgers of Sara - MEDIUM Coding Problem | CodeTikki