CT63361

Odin's Middle So Far Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the river town of Willowford; Odin weighs the day's beacons 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: 14 -231717600 -279056122 -306143213 758607590 416345734 -820868440 -283738243 -792978546 248444457 -948788686 -354554393 615976784 506562910 402115967
Output: -231717600 -279056122 -279056122 -279056122 -231717600 -279056122 -279056122 -283738243 -279056122 -283738243 -283738243 -283738243 -279056122 -279056122

Example 2:

Input: 2639 -67711310 851263832 649104409 -222210574 323925656 743024677 482181191 -103396532 412550153 -756538746 -111404358 669170043 -456021713 233438575 739296404 931019367 604636412 308464037 -278090860 810517741 -823898329 -496050156 997073939 -977576576 568296752 517795214 -471878658 -589057361 158671679 313287257 -13789136 -815868540 862774260 36948543 -120248824 -274956087 -793435383 514383553 -758775438 -857927453 605692707 793787442 -682214050 704442078 -975002312 114865970 -5235593 -316884262 -698925107 809216746 -720110568 -756703861 416719256 797392366 -160764251 390240087 -202602676 856866775 406153419 -376351618 -634410110 -834168742 -588131284 446611551 867033696 3771125 -775922571 307048749 -124746509 -297719800 329999351 590235872 -842212762 800897627 -102719640 365792467 -9824…
Output: -67711310 -67711310 649104409 -67711310 323925656 323925656 482181191 323925656 412550153 323925656 323925656 323925656 323925656 233438575 323925656 323925656 412550153 323925656 323925656 323925656 323925656 308464037 323925656 308464037 323925656 323925656 323925656 308464037 308464037 308464037 308464037 233438575 308464037 233438575 233438575 158671679 158671679 158671679 158671679 36948543 158671679 158671679 158671679 158671679 158671679 114865970 114865970 36948543 36948543 36948543 36948543 -5235593 36948543 36948543 36948543 36948543 36948543 36948543 114865970 36948543 36948543 -5235593 -5235593 -5235593 36948543 3771125 3771125 3771125 3771125 -5235593 3771125 3771125 3771125 3771125 3771125 3771125 3771125 3771125 36948543 3771125 36948543 36948543 114865970 114865970 11486597…

Example 3:

Input: 36 -721490612 716208744 -529660367 -227245261 -489428738 -273800203 -83135040 990615989 15891296 -932563716 584641184 501514607 359570891 -73624746 935159461 53034603 -613042861 311824158 -728396892 -371434309 400118233 -583750079 738783714 334357366 674641429 -400836377 324749935 -393822838 -416508488 61558489 -760689388 208983130 664910698 826627379 962382742 -835650276
Output: -721490612 -721490612 -529660367 -529660367 -489428738 -489428738 -273800203 -273800203 -227245261 -273800203 -227245261 -227245261 -83135040 -83135040 -73624746 -73624746 -73624746 -73624746 -73624746 -83135040 -73624746 -83135040 -73624746 -73624746 15891296 -73624746 15891296 -73624746 -73624746 -73624746 -73624746 -73624746 15891296 15891296 53034603 15891296

Constraints:

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

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