CT63731

The Beryl Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the willow walks of Reedmarsh pays by the answer, and Iris intends to earn it. First: the full register of ledgers. 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: 3766 744072836 -691050481 -618244748 -548426055 431380311 946149153 931601820 -423833925 265885026 -543788902 102970982 382154236 561980016 358899509 76794531 -621012999 83611845 -745084492 -114373194 663504660 -304741027 -727606880 706778289 890567844 920775244 167766340 429457737 224456947 -420163370 -803111421 299311238 -562140050 602692147 -574673863 -631459009 752182321 538596542 974401731 -819332345 -310695368 -211670323 -748999546 159810491 -988347115 45555239 -519471419 522482719 472519536 179756623 659590746 -423504202 365147706 239644632 754155642 21046652 -652731537 851285150 -528188468 425597163 -198688238 42636781 983580604 -542217089 595890016 -780135566 -767578631 489741950 903701479 -487468462 88820039 927574361 -716081012 311150332 -370914009 686558206 -53245563 904241335 …
Output: 744072836 -691050481 -618244748 -618244748 -548426055 -548426055 431380311 -423833925 265885026 -423833925 102970982 102970982 265885026 265885026 265885026 102970982 102970982 83611845 83611845 83611845 83611845 76794531 83611845 83611845 102970982 102970982 167766340 167766340 167766340 102970982 167766340 102970982 167766340 102970982 102970982 102970982 167766340 167766340 167766340 102970982 102970982 83611845 102970982 83611845 83611845 76794531 83611845 83611845 102970982 102970982 102970982 102970982 159810491 159810491 159810491 102970982 159810491 102970982 159810491 102970982 102970982 102970982 102970982 102970982 102970982 83611845 102970982 102970982 102970982 88820039 102970982 88820039 102970982 88820039 102970982 88820039 102970982 88820039 102970982 102970982 102970982 88…

Example 2:

Input: 3493 425161049 237393550 254214981 288054283 -787420508 -789792192 -527318766 980843571 658087324 35699055 238452844 -538592219 -300239477 -579955087 -362203700 -125760041 -721757071 -361465080 -904589316 -950188276 -500401961 -127155622 224808116 743280195 -282744882 281886408 163377386 17461975 -110726489 757442728 596952769 -873894506 -653424014 -71310031 472160135 937851623 -568363683 -948176984 661308674 779869396 -187269652 -27237241 34575330 -21941283 426129025 720169473 -739993636 -657940187 534737689 -50719233 385818398 -300825816 -208322623 749580851 -770194101 -608197155 -207830290 665173602 -40354175 -522177331 203755558 325616470 311795205 -244958445 -972503753 -488838380 -322995902 -800336244 248817062 -240528144 -13058749 -570487732 809694044 -108761470 782611224 738473857 -…
Output: 425161049 237393550 254214981 254214981 254214981 237393550 237393550 237393550 254214981 237393550 238452844 237393550 237393550 35699055 35699055 -125760041 -125760041 -300239477 -300239477 -361465080 -361465080 -361465080 -300239477 -300239477 -282744882 -282744882 -127155622 -127155622 -125760041 -125760041 -110726489 -125760041 -125760041 -125760041 -110726489 -110726489 -110726489 -125760041 -110726489 -110726489 -110726489 -110726489 -71310031 -71310031 -27237241 -27237241 -27237241 -71310031 -27237241 -50719233 -27237241 -50719233 -50719233 -50719233 -50719233 -71310031 -71310031 -71310031 -50719233 -71310031 -50719233 -50719233 -40354175 -50719233 -50719233 -71310031 -71310031 -110726489 -71310031 -110726489 -71310031 -110726489 -71310031 -108761470 -71310031 -71310031 -71310031 -…

Example 3:

Input: 3604 -526377664 -707612130 573819795 430040060 -913679777 -231026029 228362381 216893247 -735330196 300725171 -947382546 730600406 -991185747 442399223 464024257 695824114 -387992035 171435815 197039402 910348085 -9965707 -103412960 -859255451 -673349 170981517 -445485637 -989321819 126409793 -538093394 -475289229 -357241755 667986928 237550128 808133512 22938884 -462084268 -862437381 -810199631 -502473921 -456842553 630857490 835913022 -156250999 -141270528 -770878969 813098930 424612619 662051312 -395470800 -318338743 -515075743 185961536 128396075 823053102 -569192123 553989176 -241987583 216834154 418208189 245900359 153939752 -803083568 662672040 710937864 259720371 -362910873 484033377 -935828115 317216330 -991389523 185487498 249624453 -324223843 54665578 187587232 -565227945 -48681…
Output: -526377664 -707612130 -526377664 -526377664 -526377664 -526377664 -231026029 -231026029 -231026029 -231026029 -231026029 -231026029 -231026029 -231026029 216893247 216893247 216893247 171435815 197039402 197039402 197039402 171435815 171435815 -673349 170981517 -673349 -673349 -673349 -673349 -9965707 -9965707 -9965707 -673349 -673349 22938884 -673349 -673349 -9965707 -9965707 -103412960 -9965707 -9965707 -9965707 -103412960 -103412960 -103412960 -9965707 -9965707 -9965707 -103412960 -103412960 -103412960 -9965707 -9965707 -9965707 -9965707 -9965707 -9965707 -673349 -673349 22938884 -673349 22938884 22938884 126409793 22938884 126409793 22938884 126409793 22938884 126409793 126409793 126409793 54665578 126409793 54665578 54665578 54665578 126409793 54665578 54665578 54665578 54665578 27487…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Beryl Middle So Far - MEDIUM Coding Problem | CodeTikki