CT58141

The Mossy ledgers of Varun

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the anvil district of Hammerfall, Varun the store warden keeps careful count of the ledgers. plan the beacon maintenance rota, 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: 1645 -297946710 -910260413 321577697 -924208892 877021463 -455073974 -667605315 -671711873 -677041557 9305759 -512241972 -209716839 228146812 -182894092 641931176 -816399611 -423146766 194235843 -146322328 -637846248 -755028488 -926683618 220823105 966182840 -606632977 -534039057 -161934498 2845724 -904379869 886415370 -111614906 -393593494 -352659286 -533258398 422241286 -344843346 920434723 -179886906 528876921 425078722 545263075 969241946 601870829 168140877 439657544 -902510230 -730913851 -357330503 745844377 161061040 -263921636 -593167760 837201494 898619104 933094460 908084990 -606781843 993909171 -906665434 -979653445 491326175 -601887985 746282502 -105996945 -809932546 -926325291 -395025019 -67894005 -662419216 -116884565 9876563 -410904680 -382810969 -537927679 457577702 -554466…
Output: -297946710 -910260413 -297946710 -910260413 -297946710 -455073974 -455073974 -667605315 -667605315 -667605315 -512241972 -512241972 -455073974 -455073974 -297946710 -455073974 -423146766 -423146766 -297946710 -423146766 -423146766 -455073974 -423146766 -423146766 -423146766 -455073974 -423146766 -423146766 -423146766 -423146766 -297946710 -393593494 -352659286 -393593494 -352659286 -352659286 -344843346 -344843346 -297946710 -297946710 -209716839 -209716839 -182894092 -182894092 -179886906 -182894092 -182894092 -209716839 -182894092 -182894092 -182894092 -209716839 -182894092 -182894092 -179886906 -179886906 -179886906 -179886906 -179886906 -182894092 -179886906 -182894092 -179886906 -179886906 -179886906 -182894092 -182894092 -182894092 -182894092 -182894092 -179886906 -182894092 -1828940…

Example 2:

Input: 3429 -920724852 113517816 -43378495 -7694084 827026786 673678343 -657285649 -956144258 355256389 -45285429 577729124 150724187 -977646563 536055227 -338665589 -764566806 -429322121 677949185 -456254443 -918121764 -135485929 -417452778 800035260 -847884147 -654513468 -825231603 -5508199 -185988748 -22095983 505952789 619594299 556866874 -135103680 -784716905 728152720 965802619 -161906251 97864709 795614098 -625777596 -70669097 -538256580 -275717344 -286637115 -703098859 821024617 599758796 992641585 428768602 468123137 -519486181 -668870002 168939108 -226914440 -899271750 -761377843 816843668 -104616542 531601788 -844320722 -919295754 194009111 -763440148 759774626 859925189 -155982611 -835472062 701211210 -737347832 -107900224 272566379 -952966450 853866930 -569709825 457308080 143953415 …
Output: -920724852 -920724852 -43378495 -43378495 -7694084 -7694084 -7694084 -43378495 -7694084 -43378495 -7694084 -7694084 -7694084 -7694084 -7694084 -43378495 -43378495 -43378495 -43378495 -45285429 -45285429 -135485929 -45285429 -135485929 -135485929 -338665589 -135485929 -185988748 -135485929 -135485929 -45285429 -45285429 -45285429 -135103680 -45285429 -45285429 -45285429 -45285429 -43378495 -45285429 -45285429 -70669097 -70669097 -135103680 -135103680 -135103680 -70669097 -70669097 -45285429 -45285429 -45285429 -70669097 -45285429 -70669097 -70669097 -135103680 -70669097 -104616542 -70669097 -104616542 -104616542 -104616542 -104616542 -104616542 -70669097 -104616542 -104616542 -104616542 -104616542 -107900224 -104616542 -107900224 -104616542 -107900224 -104616542 -104616542 -70669097 -706690…

Example 3:

Input: 3702 208648821 -359491146 -187641349 738552801 577058096 -897453078 -310745587 -251592097 334462958 404160599 522616674 95759264 492874904 796069793 760042621 956989109 561794286 -381363029 -792583183 -927935711 878412956 765291899 -167606615 112451090 518507768 -886028817 985381451 249576057 -666603144 -743428004 699843748 -767836272 -842754562 41059365 65510655 323537008 -630162827 381397746 -430475056 -761819137 -398849974 -492003337 -591326318 -382169988 -270893713 -943020204 918666000 -782831538 -432178836 -234990253 -525523052 -57865866 -663478804 -989008311 576510485 989011935 522149863 145522340 806511242 -426116359 836595729 674654663 719422954 360953165 -214903339 -619741788 -576652475 999048689 -437177735 318825935 213675865 10522071 594829714 -963654305 -18366635 -814494298 -25…
Output: 208648821 -359491146 -187641349 -187641349 208648821 -187641349 -187641349 -251592097 -187641349 -187641349 208648821 95759264 208648821 208648821 334462958 334462958 404160599 334462958 334462958 208648821 334462958 334462958 334462958 208648821 334462958 208648821 334462958 249576057 249576057 208648821 249576057 208648821 208648821 112451090 112451090 112451090 112451090 112451090 112451090 95759264 95759264 65510655 65510655 41059365 41059365 -167606615 41059365 -167606615 -167606615 -187641349 -187641349 -187641349 -187641349 -234990253 -187641349 -187641349 -167606615 -167606615 -57865866 -167606615 -57865866 -57865866 41059365 41059365 41059365 -57865866 -57865866 -57865866 -57865866 -57865866 41059365 10522071 41059365 10522071 10522071 -18366635 -18366635 -18366635 10522071 -18366…

Constraints:

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

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