CT60110

Starlit signals Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the lotus ponds of Tranquil Basin pays by the answer, and Grey intends to earn it. First: the full register of signals. 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: 1179 -773082898 925643776 -858507195 -996823263 684073197 -265800665 -271481686 258192933 979935922 -218219736 -621918447 -286879299 854661671 221961829 338407358 61215499 -633337272 -996094897 -497715342 336446027 558100250 105382048 405323480 570162151 492868578 983073219 155199727 -501641088 -962335905 401138223 95085831 996409602 506802756 159278263 -10668962 -395514462 -208316998 307628741 -938353042 -961223030 -201642996 -495313788 778248582 -492391853 831607254 -954780739 -415883925 902740895 -300820294 -190806306 119140991 -58319826 -985754100 -229396447 -474756122 -449619757 238893799 -724121322 721482663 -299526964 -406167618 874135456 390858903 -388348300 12461406 548922143 687487504 -723787351 -345299714 932499752 808328305 626392015 486867554 377542712 178203404 466224571 -401…
Output: -773082898 -773082898 -773082898 -858507195 -773082898 -773082898 -271481686 -271481686 -265800665 -265800665 -265800665 -271481686 -265800665 -265800665 -218219736 -218219736 -218219736 -265800665 -265800665 -265800665 -218219736 -218219736 61215499 61215499 105382048 105382048 155199727 105382048 105382048 105382048 105382048 105382048 155199727 155199727 155199727 105382048 105382048 105382048 105382048 95085831 95085831 61215499 95085831 61215499 95085831 61215499 61215499 61215499 61215499 -10668962 61215499 -10668962 -10668962 -58319826 -58319826 -190806306 -58319826 -190806306 -58319826 -190806306 -190806306 -190806306 -58319826 -190806306 -58319826 -58319826 -10668962 -58319826 -58319826 -58319826 -10668962 -10668962 12461406 12461406 61215499 61215499 61215499 61215499 95085831 95…

Example 2:

Input: 3846 20724486 747405498 548667212 -334366936 697762506 7143013 519507876 -162372271 -228257230 -852778053 117271581 -166484852 -37362766 -820369850 889243712 -151949133 289961894 -335288338 189926276 904280646 192258418 -82767766 102675529 -546905669 486259148 -209735712 -369239036 -251485934 -951912981 -235179369 -298696159 6999777 -592380660 -577952864 -57538262 274814322 -478183249 505189557 -180652370 -10091859 -864461098 543192563 763726199 156030220 -445438442 -194312402 -222055958 693897900 -761361098 -617941595 726290838 -985099459 725004692 -805130733 -67066796 -455462956 651890199 -392197754 -497810071 -71883521 -899521088 885610426 -690131372 -259682987 73694444 -613819468 777330094 357825840 -325316805 -657471762 -246192749 352424450 -777629203 -357381948 -126513018 704238120 -…
Output: 20724486 20724486 548667212 20724486 548667212 20724486 519507876 20724486 20724486 7143013 20724486 7143013 7143013 -37362766 7143013 -37362766 7143013 -37362766 7143013 7143013 20724486 7143013 20724486 7143013 20724486 7143013 7143013 -37362766 -37362766 -82767766 -82767766 -82767766 -82767766 -151949133 -82767766 -82767766 -82767766 -82767766 -82767766 -82767766 -82767766 -82767766 -57538262 -57538262 -57538262 -82767766 -82767766 -82767766 -82767766 -151949133 -82767766 -151949133 -82767766 -151949133 -82767766 -151949133 -82767766 -151949133 -151949133 -151949133 -151949133 -151949133 -151949133 -162372271 -151949133 -162372271 -151949133 -151949133 -151949133 -162372271 -162372271 -162372271 -162372271 -166484852 -162372271 -162372271 -162372271 -166484852 -162372271 -162372271 -151…

Example 3:

Input: 571 -53974461 159086022 177653329 339262029 794456862 625186213 -314671713 -908072417 -11185599 -704532460 -559773963 213521869 -121904996 444364969 491083955 -705724876 662048208 -362302498 660026846 905666097 -417490370 245819264 230459470 282336527 620364226 334102592 -347339744 -70212615 -449417659 566341772 -247649636 -726433612 -979510664 -394015946 337643008 221957884 964406751 696362329 -197267234 835995687 755223815 -895492295 657281174 -640229533 864841361 138978847 -946842737 -872248524 428979582 397392295 -501491600 188705270 757652074 -562097680 787892278 122567317 960642809 -916647 -502717256 631647434 -755458306 -117365602 -775131241 -987393714 -349584226 -870639601 207529367 36189355 -742505337 601938690 -456009 -446658937 54808909 73643284 -45528004 -161758528 -816036088 -…
Output: -53974461 -53974461 159086022 159086022 177653329 177653329 177653329 159086022 159086022 -11185599 -11185599 -11185599 -11185599 -11185599 159086022 -11185599 159086022 -11185599 159086022 159086022 159086022 159086022 177653329 177653329 213521869 213521869 213521869 177653329 177653329 177653329 177653329 159086022 159086022 -11185599 159086022 159086022 177653329 177653329 177653329 177653329 213521869 177653329 213521869 177653329 213521869 177653329 177653329 159086022 177653329 177653329 177653329 177653329 188705270 177653329 188705270 177653329 188705270 177653329 177653329 177653329 177653329 159086022 159086022 138978847 138978847 122567317 138978847 122567317 122567317 122567317 122567317 36189355 54808909 54808909 54808909 36189355 36189355 -456009 -456009 -916647 -916647 -111…

Constraints:

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

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