CT61828

Cleo's Rustic Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the smokehouses of Brineport, Cleo records each signals in a worn leather ledger. The guild wants answers, not guesses. 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: 1728 87127728 860903106 110771603 -560876025 936994157 293197830 -688060072 664463053 -588098387 418728476 800448592 302993387 -18397806 309385026 195198589 546821687 768153931 -454831537 -405992821 -374431293 -121736556 -269737284 34318819 203640484 -286587812 896468719 -951266535 -71981270 -568964722 290324739 -377628830 -633801356 -970233486 405135299 664330243 -836385300 -552599574 -995290592 -490391073 359172214 -915449818 -271731816 696562155 241308547 537866276 344537324 275037550 530096716 -167775374 760870479 710276282 297182026 -175984400 -995676729 -967027696 -424142742 -429276714 990467423 142733639 -535975611 -757647276 -652542466 -735969543 124782182 -214724395 -402901710 -211098198 -954110652 -494225453 -122977712 959503684 775351280 574741805 690777124 -531700275 -310734961…
Output: 87127728 87127728 110771603 87127728 110771603 110771603 110771603 110771603 110771603 110771603 293197830 293197830 293197830 293197830 293197830 293197830 302993387 293197830 293197830 195198589 195198589 110771603 110771603 110771603 110771603 110771603 110771603 87127728 87127728 87127728 87127728 34318819 34318819 34318819 87127728 34318819 34318819 -18397806 -18397806 -18397806 -18397806 -71981270 -18397806 -18397806 34318819 34318819 87127728 87127728 87127728 87127728 110771603 110771603 110771603 87127728 87127728 34318819 34318819 34318819 87127728 34318819 34318819 -18397806 -18397806 -18397806 -18397806 -71981270 -71981270 -121736556 -121736556 -122977712 -121736556 -121736556 -71981270 -71981270 -71981270 -121736556 -121736556 -121736556 -71981270 -121736556 -108509239 -121736…

Example 2:

Input: 3985 661671253 34037721 779045967 -926071873 418134181 415267733 718682015 -516918964 922170352 -806580656 93126674 -813109688 -671725934 961709654 492321543 975398224 -488860860 -89657365 552306774 -235226935 378581450 480321269 -959900495 -992345013 -122016822 543441564 184331914 -337423744 827496690 -333207337 -149960775 122333097 512805472 -392339800 -652808862 646336236 179808477 -927451252 -987070981 -398237577 -635653411 885745039 -851436101 -601455689 553735874 -35544259 854529812 -166816994 343693059 -491893666 -553260873 893100690 319543349 900640221 -954574264 -813415376 -98230705 380997841 -276821159 928776640 -272324382 871658831 -536270859 -632495893 -910489952 -898436657 266140064 197059485 -407700298 416701064 291711298 61726431 -843308798 51818292 293101291 -466413132 8880…
Output: 661671253 34037721 661671253 34037721 418134181 415267733 418134181 415267733 418134181 415267733 415267733 93126674 93126674 93126674 415267733 415267733 415267733 93126674 415267733 93126674 378581450 378581450 378581450 93126674 93126674 93126674 184331914 93126674 184331914 93126674 93126674 93126674 122333097 93126674 93126674 93126674 122333097 93126674 93126674 34037721 34037721 34037721 34037721 -89657365 34037721 -35544259 34037721 -35544259 34037721 -35544259 -35544259 -35544259 34037721 34037721 34037721 -35544259 -35544259 -35544259 -35544259 -35544259 -35544259 -35544259 -35544259 -89657365 -89657365 -98230705 -89657365 -89657365 -89657365 -89657365 -35544259 -35544259 -35544259 -35544259 34037721 -35544259 34037721 34037721 51818292 34037721 34037721 34037721 51818292 5181829…

Example 3:

Input: 1420 -266884635 -945802863 -382780100 -358840618 200517716 563018522 -197623775 -728049915 -936204596 695642350 374136793 183741125 247202543 713092872 185134980 -331672784 -413741859 704927649 751359210 747759602 250571101 -922499323 -442333818 538770192 -500574440 725212618 871538667 630318656 91407215 711202705 -490956123 101938283 927662813 683775261 -304445792 96157845 131536016 174007272 -382991661 921581832 761671193 -82088326 104182949 936794693 -468768186 614776414 524230833 -77935771 -234093706 902504582 -20310382 686910327 804781479 -603218100 818148574 -781028425 998786243 882292953 313037302 99955757 -82811242 418483984 136186874 111476819 -588423756 -872139108 -25706061 796334369 111964532 844070459 367881718 -249784425 -688616113 372595759 898687035 177700621 968161799 -5296…
Output: -266884635 -945802863 -382780100 -382780100 -358840618 -358840618 -266884635 -358840618 -358840618 -358840618 -266884635 -266884635 -197623775 -197623775 183741125 -197623775 -197623775 -197623775 183741125 183741125 185134980 183741125 183741125 183741125 183741125 183741125 185134980 185134980 185134980 185134980 185134980 183741125 185134980 185134980 185134980 183741125 183741125 174007272 174007272 174007272 183741125 174007272 174007272 174007272 174007272 174007272 183741125 174007272 174007272 174007272 174007272 174007272 183741125 174007272 183741125 174007272 183741125 183741125 185134980 183741125 183741125 183741125 183741125 174007272 174007272 136186874 136186874 136186874 136186874 136186874 174007272 136186874 136186874 136186874 174007272 174007272 177700621 174007272 177…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Cleo's Rustic Ledger - MEDIUM Coding Problem | CodeTikki