CT58403

The ledgers at Echo Dunes

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the singing sands of Echo Dunes opens only for a perfect tally of ledgers. Yami means to find out. 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: 3515 508396687 374252782 348081027 136465643 464756760 453017947 880536635 -976751865 454323679 140625531 850914266 48802299 -613375086 -280889667 -460327601 852104229 425851123 -67575522 -492621411 531263770 -351465377 320147964 88693279 402405590 -381297963 -453960922 -697730531 423563963 881818956 -214634779 -772851714 -573040224 491513373 920286665 463701813 385497814 753372761 -196271770 35954232 -617073984 723428873 560167162 -628884397 -846848835 918227964 -598067727 253063631 -214716088 843824151 81701360 525929037 3480015 -796591094 -966705325 -947796476 125511952 -301353713 245166813 570709741 -431074919 -927415783 -67294580 122721143 111605285 444024022 -170551932 597314579 592084867 -124319523 -897959665 656536454 -936132689 760462030 -633230119 -910777218 -414758223 206501438 …
Output: 508396687 374252782 374252782 348081027 374252782 374252782 453017947 374252782 453017947 374252782 453017947 374252782 374252782 348081027 348081027 348081027 374252782 348081027 348081027 348081027 348081027 320147964 320147964 320147964 320147964 140625531 140625531 140625531 320147964 140625531 140625531 136465643 140625531 140625531 320147964 320147964 348081027 320147964 320147964 140625531 320147964 320147964 320147964 140625531 320147964 140625531 253063631 140625531 253063631 140625531 253063631 140625531 140625531 136465643 136465643 125511952 125511952 125511952 136465643 125511952 125511952 88693279 122721143 111605285 122721143 111605285 122721143 122721143 122721143 111605285 122721143 111605285 122721143 111605285 111605285 88693279 111605285 88693279 88693279 81701360 88693…

Example 2:

Input: 1707 152538091 -139878772 756766071 -492601796 26287066 -506390881 447031297 -528902011 764903688 898623652 -99008092 975446259 49303174 -288609399 703657727 -99756048 805860127 -448586584 135626126 237088208 794643260 -373623661 151124033 -154473708 -845344937 346144792 -150301335 343140499 4553726 -855408302 -835781126 -449838454 -633578238 -817367213 211471743 -67381609 491471893 239403454 184417768 680929639 -716724505 -293935829 213410879 -29632263 970480789 -851813378 9791390 -243906340 901036838 -22206164 109578787 -678249349 321509575 764370995 159938867 -875274913 754594094 872558344 387912619 387053937 985747735 -99361298 -427548070 -256941883 123428590 -540627755 -608000951 -28244930 -656479625 91923977 701389223 439602112 -601234317 994239607 -860116600 -731157941 972435456 457…
Output: 152538091 -139878772 152538091 -139878772 26287066 -139878772 26287066 -139878772 26287066 26287066 26287066 26287066 49303174 26287066 49303174 26287066 49303174 26287066 49303174 49303174 135626126 49303174 135626126 49303174 49303174 49303174 49303174 49303174 49303174 26287066 26287066 4553726 4553726 -99008092 4553726 -67381609 4553726 4553726 26287066 26287066 26287066 4553726 26287066 4553726 26287066 4553726 9791390 4553726 9791390 4553726 9791390 4553726 9791390 9791390 26287066 9791390 26287066 26287066 49303174 49303174 109578787 49303174 49303174 26287066 49303174 26287066 26287066 9791390 9791390 9791390 26287066 26287066 26287066 26287066 26287066 9791390 26287066 26287066 49303174 26287066 26287066 9791390 9791390 9791390 9791390 4553726 9791390 4553726 4553726 4553726 97913…

Example 3:

Input: 2540 495248211 -732256284 805084295 802544524 -319334421 549529726 214001776 -741468772 207094169 -261620810 -926987809 -519790229 291578963 12894601 868525256 -90599740 -8983312 -645451471 -452383607 823055579 -100181998 -67428578 -869411815 -184025641 514179927 -772048765 -620278547 70821557 -809671178 -694649448 52409078 901203413 -329489910 -485001124 58282627 398376766 -520749058 -336044479 -671117999 -2248578 991412039 801753300 420256494 755395487 453842110 -498473738 -270043643 -170410203 -477858757 -83643696 741688811 156419977 950638506 597113305 7009004 -287115859 512730039 -898800911 646487236 -467784353 655943607 864501092 81858853 -138344559 614151395 639013302 -458100872 -147314244 326404807 99561058 -736065368 104405523 -318032326 637866909 -57403100 -521921403 -72826 85209…
Output: 495248211 -732256284 495248211 495248211 495248211 495248211 495248211 214001776 214001776 207094169 207094169 -261620810 207094169 12894601 207094169 12894601 12894601 -8983312 -8983312 -8983312 -8983312 -67428578 -67428578 -90599740 -67428578 -90599740 -90599740 -90599740 -90599740 -100181998 -90599740 -90599740 -90599740 -100181998 -90599740 -90599740 -90599740 -100181998 -100181998 -100181998 -90599740 -90599740 -67428578 -67428578 -8983312 -67428578 -67428578 -90599740 -90599740 -90599740 -83643696 -83643696 -67428578 -67428578 -8983312 -67428578 -8983312 -67428578 -8983312 -67428578 -8983312 -8983312 -2248578 -8983312 -2248578 -2248578 -2248578 -8983312 -2248578 -2248578 -2248578 -2248578 -2248578 -2248578 -2248578 -8983312 -2248578 -2248578 -2248578 -2248578 -72826 -2248578 -2248578…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The ledgers at Echo Dunes - MEDIUM Coding Problem | CodeTikki