CT60131

Trader's Middle So Far Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the zephyr cliffs of Galeholm; Trader weighs the day's ledgers manifests and starts the calculations. 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: 1848 968060375 -163676661 771066772 49309864 196118251 809132858 758531987 490845913 865471358 -20139166 -761937495 -840984442 928085307 74601376 28028447 895337936 902439053 -880341938 977947274 313996748 -198955008 -86399334 -753100338 214064703 -254869534 -858238118 -342769222 -661041407 743830718 424487402 422949857 308512535 79087785 -575837111 -191904454 -629282848 -811646668 -118689107 -692193301 -758492139 990944267 48783636 -791158204 545350650 -374477310 -824188181 -993545356 -964096504 429242364 -18348811 410681183 -209330706 676274312 990468481 883254225 -502522413 8585589 698862157 511099751 -792342144 548007271 -877631744 88031546 907387379 60215114 456686927 964300571 -230022038 344132864 -747270787 -84549592 -234040423 774475418 -488709377 869481512 396731787 -290447841 296…
Output: 968060375 -163676661 771066772 49309864 196118251 196118251 758531987 490845913 758531987 490845913 490845913 196118251 490845913 196118251 196118251 196118251 490845913 196118251 490845913 313996748 313996748 196118251 196118251 196118251 196118251 74601376 74601376 49309864 74601376 74601376 196118251 196118251 196118251 79087785 79087785 74601376 74601376 49309864 49309864 28028447 49309864 48783636 48783636 48783636 48783636 28028447 28028447 -20139166 28028447 -18348811 28028447 -18348811 28028447 28028447 48783636 28028447 28028447 28028447 48783636 28028447 48783636 28028447 48783636 48783636 49309864 49309864 60215114 49309864 60215114 49309864 49309864 48783636 49309864 48783636 49309864 49309864 49309864 49309864 60215114 60215114 60215114 60215114 60215114 60215114 60215114 4930…

Example 2:

Input: 1191 322085780 -511864288 -279502444 -46007037 161528668 -937763416 894999454 -867937500 -563951078 478889729 916066012 802334224 -287009453 -57429641 -451652942 -628660035 -910722520 -763788219 436089566 59852714 -218883594 952921839 73255919 791250126 128415647 -113793418 -309614991 253398787 942906402 839171489 452310576 699338979 -700053612 835245915 -151042554 -266799622 147124488 189127523 691280661 776741670 841135103 -207375258 510509424 -525552266 -17050691 -370533188 -489195674 -894682902 211394532 -914831523 327178113 -54847444 727598520 -858164079 -654146625 156714962 474450990 704563026 -950756983 318736664 -574540773 272439436 358706394 -619887848 -558776392 399644691 -678598166 48096199 -648757472 -254777248 833328225 873090791 -12475507 -561085093 22065052 -724462397 -23829…
Output: 322085780 -511864288 -279502444 -279502444 -46007037 -279502444 -46007037 -279502444 -279502444 -279502444 -46007037 -46007037 -46007037 -57429641 -57429641 -279502444 -279502444 -287009453 -279502444 -279502444 -218883594 -218883594 -57429641 -57429641 -46007037 -57429641 -57429641 -57429641 -46007037 -46007037 59852714 59852714 59852714 59852714 59852714 -46007037 59852714 59852714 73255919 73255919 128415647 73255919 128415647 73255919 73255919 59852714 59852714 -17050691 59852714 -17050691 59852714 -17050691 59852714 -17050691 -17050691 -17050691 59852714 59852714 59852714 59852714 59852714 59852714 73255919 59852714 59852714 59852714 59852714 48096199 48096199 -17050691 48096199 48096199 48096199 -12475507 22065052 -12475507 -12475507 -17050691 -12475507 -12475507 -5957970 -5957970 -5…

Example 3:

Input: 1258 -21777592 -163351689 -711885416 205798257 -747928663 -436817281 -364060214 -564854942 -169672261 219826322 33899779 627890995 242612206 429168940 559510359 611647737 -789839910 -78392600 559859068 364423734 -552296758 56544203 -671572649 80614568 -797630156 -931988388 180917183 825886638 -251542734 -597446755 365933746 697526676 -378961327 4407961 -775176330 717653204 994414028 890643602 918160691 284260472 988980191 -564617996 -969663611 -436149244 342980418 142050017 578940040 -923623851 -867393104 964340818 -58769951 -373581460 -288241510 173770391 389009234 -895780810 896266228 183973838 -843033200 -120835821 25610148 -894717733 -503198967 104912621 -283457940 -39598079 276026206 664114183 615477198 395659281 250909789 508984290 -578367791 -674400455 -100195149 216195706 -91353537…
Output: -21777592 -163351689 -163351689 -163351689 -163351689 -436817281 -364060214 -436817281 -364060214 -364060214 -169672261 -169672261 -163351689 -163351689 -21777592 -21777592 -21777592 -78392600 -21777592 -21777592 -21777592 -21777592 -21777592 -21777592 -21777592 -78392600 -21777592 -21777592 -21777592 -78392600 -21777592 -21777592 -21777592 -21777592 -21777592 -21777592 4407961 4407961 33899779 33899779 56544203 33899779 33899779 4407961 33899779 33899779 56544203 33899779 33899779 33899779 33899779 4407961 4407961 4407961 33899779 4407961 33899779 33899779 33899779 4407961 25610148 4407961 4407961 4407961 4407961 -21777592 4407961 4407961 25610148 25610148 33899779 33899779 33899779 25610148 25610148 25610148 25610148 25610148 25610148 4407961 25610148 25610148 25610148 25610148 33899779 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Trader's Middle So Far Ledger - MEDIUM Coding Problem | CodeTikki