CT63727

The Middle So Far of the Gilded marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the tannery row of Leatherwick, Xara studies rows of marks entries. One clean number will settle the guild's oldest argument. 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: 2711 485795266 635792598 -435162869 -224648671 -394641278 231619084 -439006788 -351746918 726733563 -547759370 757227311 -724646360 884517391 -239203038 94658023 -261846056 139570064 960964236 628465326 -311364177 650197189 641566626 962436 -471479423 -219690535 685336114 84155960 983386378 -955315094 554622599 972636915 60057288 -253895844 -115988071 -331806057 409960235 -739385018 106407445 10386482 846386151 -651599311 842350040 -105587184 -502262863 -315550727 455562311 -425881769 -702216646 -468601186 -601237581 -344429656 -653203864 -310173928 -464741280 -34900212 569597751 127116906 -487278591 941966394 -69820169 832529477 328447348 919423956 -196439207 -344154318 -29156572 424532907 -557233888 948316226 -484698658 999681997 81396394 689793915 -618348723 -399467867 -295936083 -86664…
Output: 485795266 485795266 485795266 -224648671 -224648671 -224648671 -224648671 -351746918 -224648671 -351746918 -224648671 -351746918 -224648671 -239203038 -224648671 -239203038 -224648671 -224648671 94658023 -224648671 94658023 94658023 94658023 962436 962436 962436 84155960 84155960 84155960 84155960 94658023 84155960 84155960 60057288 60057288 60057288 60057288 60057288 60057288 60057288 60057288 60057288 60057288 10386482 10386482 10386482 10386482 962436 962436 -105587184 -105587184 -115988071 -115988071 -219690535 -115988071 -115988071 -105587184 -115988071 -105587184 -105587184 -69820169 -69820169 -34900212 -69820169 -69820169 -69820169 -34900212 -69820169 -34900212 -69820169 -34900212 -34900212 -29156572 -34900212 -34900212 -69820169 -69820169 -105587184 -105587184 -105587184 -105587184…

Example 2:

Input: 78 167549961 -737833920 89773507 -832202299 419362494 281352882 39076681 -209631155 -207782156 -638180710 71600835 994139422 -675208141 -531361801 -723382186 226214289 366928447 780920188 899571089 -916505242 -177537810 875138215 765394897 639494512 -880887850 679310808 -50557579 389824247 -812492391 784922821 -125247677 -274499155 686795646 130587964 -726678902 62448704 833960487 -175347726 -332821128 274814824 -276693801 280413270 -324870869 722343533 -613409113 557377769 527924179 -577495760 839863404 707288948 -231433035 -426102098 819707307 264281080 -753063026 658615100 793628867 -111297262 717771351 557881993 672463596 -133219686 -749351563 -274070683 560863052 709810383 -265635679 61720532 880451182 -707630316 534466727 135648915 439853439 -918725074 854055741 248367175 736977986 -…
Output: 167549961 -737833920 89773507 -737833920 89773507 89773507 89773507 39076681 39076681 -207782156 39076681 39076681 39076681 -207782156 -207782156 -207782156 39076681 39076681 71600835 39076681 39076681 39076681 71600835 71600835 71600835 71600835 71600835 71600835 71600835 71600835 71600835 39076681 71600835 71600835 71600835 62448704 71600835 62448704 62448704 62448704 62448704 62448704 62448704 62448704 62448704 62448704 71600835 62448704 71600835 71600835 71600835 62448704 71600835 71600835 71600835 71600835 89773507 71600835 89773507 89773507 130587964 89773507 89773507 71600835 89773507 89773507 89773507 71600835 89773507 71600835 89773507 89773507 130587964 89773507 130587964 130587964 135648915 130587964

Example 3:

Input: 1637 590115231 70980584 -487984390 -446470166 436636562 626062290 -836732295 197048303 397226511 -634715144 -168783493 -425602994 469491845 -381591378 -212545549 -734983745 962132149 699337749 -588377026 -963707487 -136528718 407999844 -792959270 90735425 82272942 323313024 622674699 -339985930 934707779 -652243159 -460365639 750879042 368593574 -781773105 51206215 883858057 908065237 -230116755 -822778802 -313498414 43664210 315440936 420639409 445220385 -638384075 556071550 176182080 662514191 976216495 -323080984 -192604656 -477791666 208499357 160637082 -783309668 -908493889 547192582 612396422 281900489 -375191080 61041995 60615744 -606320486 758553029 540284762 -560450164 -101842441 -720094497 -82368968 836195413 978228677 841258763 520479847 317566060 -447000346 289583696 -134282862…
Output: 590115231 70980584 70980584 -446470166 70980584 70980584 70980584 70980584 197048303 70980584 70980584 -168783493 70980584 -168783493 -168783493 -212545549 -168783493 -168783493 -168783493 -212545549 -168783493 -168783493 -168783493 -168783493 -136528718 -136528718 70980584 -136528718 70980584 -136528718 -136528718 -136528718 70980584 -136528718 51206215 51206215 70980584 51206215 51206215 -136528718 43664210 43664210 51206215 51206215 51206215 51206215 70980584 70980584 82272942 70980584 70980584 51206215 70980584 70980584 70980584 51206215 70980584 70980584 82272942 70980584 70980584 61041995 61041995 61041995 70980584 61041995 61041995 60615744 60615744 60615744 61041995 61041995 70980584 70980584 70980584 70980584 70980584 70980584 70980584 61041995 70980584 61041995 61041995 60615744 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Middle So Far of the Gilded marks - MEDIUM Coding Problem | CodeTikki