CT63273

The Frosted registers of Boris

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Every season at the mangrove channels of Rootwater, someone must verify the ledger before the auditors arrive. This year the task falls to Boris, armed only with the registers register. 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: 3537 899260062 630246258 -324098410 -217996682 -627707725 117836641 780890340 -728103834 180524529 -119995063 -935455616 -89768820 807566655 693411322 71368326 540227923 -43832625 -222264569 175735418 716007372 -388006270 9613170 -37624016 -344230250 23150254 780996377 -54260192 455945091 -990939765 -58060987 957332833 -650095178 780008723 755619047 -378562547 -979751122 150719426 -774170017 -133106911 946828195 -370430592 -620963043 920484776 -144729328 -610398898 -251347565 728435928 200348264 385363524 309118898 -105247758 -639599052 -237849607 -316854349 -744007394 652013011 -525792077 -665524432 899903577 -901196398 721922596 775695263 954137211 378017593 -300255707 -412690301 483689682 631306752 -835395427 -843271464 169580419 -36379832 934341662 320677928 456632262 -157557546 -20542…
Output: 899260062 630246258 630246258 -217996682 -217996682 -217996682 117836641 -217996682 117836641 -119995063 -119995063 -119995063 -89768820 -89768820 71368326 71368326 71368326 -43832625 71368326 71368326 71368326 9613170 9613170 -37624016 9613170 9613170 9613170 9613170 9613170 -37624016 9613170 -37624016 9613170 9613170 9613170 -37624016 9613170 -37624016 -37624016 -37624016 -37624016 -43832625 -37624016 -43832625 -43832625 -54260192 -43832625 -43832625 -37624016 -37624016 -37624016 -43832625 -43832625 -54260192 -54260192 -54260192 -54260192 -58060987 -54260192 -58060987 -54260192 -54260192 -43832625 -43832625 -43832625 -54260192 -43832625 -43832625 -43832625 -54260192 -43832625 -43832625 -37624016 -37624016 -36379832 -37624016 -37624016 -37624016 -36379832 -36379832 -36379832 -36379832 -36…

Example 2:

Input: 2732 -936109128 -833673815 -955951842 8187015 918586540 -145235863 991662308 302760064 268200463 146738835 -398617772 -645682019 -965564085 950807818 -866379226 568885726 333195793 12283633 -678284142 225014543 -667461646 -832849942 376896529 -770147795 519624895 267529748 870015169 -192401472 811802498 -959720110 640271641 236355489 413534025 971611199 -649800949 917172630 -959884750 674488451 -671256367 674401512 691169301 -386542004 665028816 767640723 -775387859 820018498 13543316 659627622 -483578804 673205582 314045573 10925263 1478288 -677866399 -522174904 431987193 934405780 -218097468 370241891 -861919328 -598004057 263063979 -657765552 -376484890 794215932 -301679079 -395292378 97294395 107823535 -424303751 503732281 -800873214 435566470 -803071955 -254898926 589881633 -591836727…
Output: -936109128 -936109128 -936109128 -936109128 -833673815 -833673815 -145235863 -145235863 8187015 8187015 8187015 -145235863 -145235863 -145235863 -145235863 -145235863 8187015 8187015 8187015 8187015 8187015 -145235863 8187015 -145235863 8187015 8187015 12283633 8187015 12283633 8187015 12283633 12283633 146738835 146738835 146738835 146738835 146738835 146738835 146738835 146738835 225014543 146738835 225014543 225014543 225014543 225014543 225014543 225014543 225014543 225014543 236355489 225014543 225014543 146738835 146738835 146738835 225014543 146738835 225014543 146738835 146738835 146738835 146738835 13543316 146738835 13543316 13543316 13543316 97294395 13543316 97294395 13543316 97294395 13543316 13543316 13543316 13543316 13543316 97294395 97294395 97294395 13543316 97294395 9729…

Example 3:

Input: 1457 152349982 750494811 277768055 -679952125 510709268 -403075491 -57258504 -941866360 894183212 81680495 387483541 318370387 -964736052 979710954 837884940 -674784096 518399926 -48212456 -529876336 772899609 30377914 -417531121 767774311 230544080 -251981273 720724183 960883040 708783323 -885767301 -711089873 -269158847 -373712016 -108992950 -91996289 918066032 62316963 666094970 723227657 -224063886 -213974299 -360490994 -488095572 671708701 360557241 201164040 -485839640 401762956 524340431 667429696 -266755116 734750984 -60294993 -168464682 26446701 -51218920 53295282 460024190 535827532 78038518 37942159 -264091985 -382191684 8792264 972509540 -594571935 -384819097 -454360176 934382511 -624122554 283377677 891889931 -799654013 135216759 786008319 -934718768 -507434043 -933015270 -887…
Output: 152349982 152349982 277768055 152349982 277768055 152349982 152349982 -57258504 152349982 81680495 152349982 152349982 152349982 152349982 277768055 152349982 277768055 152349982 152349982 152349982 152349982 81680495 152349982 152349982 152349982 152349982 230544080 230544080 230544080 152349982 152349982 81680495 81680495 30377914 81680495 62316963 81680495 81680495 81680495 62316963 62316963 30377914 62316963 62316963 81680495 62316963 81680495 81680495 152349982 81680495 152349982 81680495 81680495 62316963 62316963 53295282 62316963 62316963 78038518 62316963 62316963 53295282 53295282 53295282 53295282 37942159 37942159 37942159 37942159 37942159 53295282 37942159 53295282 53295282 53295282 37942159 37942159 30377914 30377914 26446701 26446701 26446701 26446701 26446701 30377914 3037…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Frosted registers of Boris - MEDIUM Coding Problem | CodeTikki