CT63456

Gilded signals Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the caldera rim of Firewatch, Cartwright the reckoner keeps careful count of the signals. Schedule the next expedition, every figure matters. 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: 1676 18262675 313424388 -573762644 -239425516 -271667648 535628649 904523660 -267948050 -241427312 166163478 -972645356 -167355873 -518089114 599898752 -27890929 -79859382 -772628654 -675219867 63494043 -243198619 799673277 99519149 -668869169 -743152550 -456310787 57969637 -287076514 505478676 52953212 -947463158 -603430968 488646370 -580073116 466750068 561594654 -971597250 -689631509 -891515866 -752424917 -783610058 -750826901 324102616 -144857573 551084301 -492604558 -781522561 -760548382 -210075265 843597433 699980870 -794384006 -875904591 693047205 -977902941 413272082 -514574390 427582418 -83405983 63078431 5449444 -845176983 -729631520 371145457 319711302 33248501 741133331 -54391125 -175994217 -787274775 865263141 -94167506 876859369 -526522869 364001672 710867465 -908695714 66144…
Output: 18262675 18262675 18262675 -239425516 -239425516 -239425516 18262675 -239425516 -239425516 -239425516 -239425516 -239425516 -239425516 -239425516 -167355873 -167355873 -167355873 -239425516 -167355873 -239425516 -167355873 -167355873 -167355873 -239425516 -239425516 -239425516 -239425516 -239425516 -167355873 -239425516 -239425516 -239425516 -239425516 -239425516 -167355873 -239425516 -239425516 -241427312 -241427312 -243198619 -243198619 -243198619 -241427312 -241427312 -241427312 -243198619 -243198619 -243198619 -241427312 -241427312 -241427312 -243198619 -241427312 -243198619 -241427312 -243198619 -241427312 -241427312 -239425516 -239425516 -239425516 -241427312 -239425516 -239425516 -210075265 -210075265 -167355873 -175994217 -175994217 -175994217 -167355873 -167355873 -167355873 -1673…

Example 2:

Input: 3637 385143464 625843364 -295668111 -202010937 472170695 -646643373 -646384552 973967801 -523754246 -514389698 522261506 188870666 759300936 -111728306 731772653 793672502 -336787705 -474443344 -73267527 -938127745 722300726 -983700041 232721992 -759025154 359832875 251850462 901092719 349393769 -241868198 -141742329 -713954209 -575345073 817444555 792944557 964631407 -73756268 -590879685 -815287833 222540648 -127077075 -485115148 697487303 -727683926 947280775 577796660 186881416 52576728 225079203 142599633 -20303119 -910831616 894139326 -889294445 936242534 -754373114 54942116 121405286 -108168126 526722355 92512800 -748577932 -112271266 -510231114 556340798 620882015 439670941 437550887 893138711 254204049 -348160691 997906641 842467865 879012488 -705843447 70417303 939497241 -46396316…
Output: 385143464 385143464 385143464 -202010937 385143464 -202010937 -202010937 -202010937 -202010937 -295668111 -202010937 -202010937 188870666 -111728306 188870666 188870666 188870666 -111728306 -73267527 -111728306 -73267527 -111728306 -73267527 -111728306 -73267527 -73267527 188870666 188870666 188870666 -73267527 -73267527 -111728306 -73267527 -73267527 188870666 -73267527 -73267527 -73756268 -73267527 -73756268 -73756268 -73756268 -73756268 -73756268 -73267527 -73267527 52576728 52576728 142599633 52576728 52576728 52576728 52576728 52576728 52576728 52576728 54942116 52576728 54942116 54942116 54942116 52576728 52576728 52576728 54942116 54942116 92512800 92512800 121405286 92512800 121405286 121405286 142599633 121405286 121405286 121405286 121405286 92512800 121405286 92512800 121405286 …

Example 3:

Input: 1949 -629172288 -924130870 -481510679 -641815411 343460393 -481943679 431158050 839156615 975174296 -726881536 -690218421 -733019915 -470574469 -667998008 484359479 -224048022 46560591 -845855616 521648132 813416752 808184489 19178019 547520388 391587315 683662769 156472047 -992141536 580696067 -372263316 479016308 611797128 -763600400 955988445 -365667925 -174764818 115079357 881861490 378898356 153014779 956834876 -824695025 -886854058 -583037960 681882221 -123881185 645207563 721666919 714682828 477938437 104187683 993724105 668786657 941729153 912124891 -392095232 -908987034 754339356 660120915 -588329649 -914051370 -179490228 823864399 675380897 -274010180 -977229410 233062697 48323652 947557856 630101781 843853922 310984809 763242237 -954758798 849620059 458317681 719888977 769864080…
Output: -629172288 -924130870 -629172288 -641815411 -629172288 -629172288 -481943679 -481943679 -481510679 -481943679 -481943679 -629172288 -481943679 -629172288 -481943679 -481943679 -481510679 -481943679 -481510679 -481510679 -470574469 -470574469 -224048022 -224048022 19178019 19178019 19178019 19178019 19178019 19178019 46560591 19178019 46560591 19178019 19178019 19178019 46560591 46560591 115079357 115079357 115079357 46560591 46560591 46560591 46560591 46560591 115079357 115079357 153014779 115079357 153014779 153014779 156472047 156472047 156472047 153014779 156472047 156472047 156472047 153014779 153014779 153014779 156472047 153014779 153014779 153014779 153014779 153014779 156472047 156472047 233062697 233062697 233062697 233062697 310984809 310984809 343460393 310984809 341750045 31098…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Gilded signals Middle So Far - MEDIUM Coding Problem | CodeTikki