CT64422

Beryl beacons Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the ivy courts of Vineward as Lothar unrolls the day's manifest of beacons. The tally will decide the next shipment. 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: 636 -815155250 922440129 125600659 527809233 704330244 250869930 482276224 -815673275 -25555744 -631262290 813710126 153238174 -24345264 -568753846 -967738578 21033079 -377871112 -573278789 696537236 -889164142 -507971548 -870346229 -304353051 -540905075 -828788068 -710483465 -103675844 460242258 -272305922 -312837974 -612714964 -651616218 -286767621 126779506 590233376 -308966360 -808825942 966697080 294238988 -49281337 759448405 -642384247 414390793 -183863704 -372565648 -158135404 14374100 608772017 750918631 362238646 -135471326 312938492 -893035825 844115857 -218636382 547254724 53038507 124742432 807552839 470412678 634471150 -109633477 296740279 138089152 -470202685 -836511445 204259002 -808732547 568016335 755931385 738907374 -930048260 395890003 569155594 -732984054 -706102977 330…
Output: -815155250 -815155250 125600659 125600659 527809233 250869930 482276224 250869930 250869930 125600659 250869930 153238174 153238174 125600659 125600659 21033079 21033079 -24345264 21033079 -24345264 -24345264 -25555744 -25555744 -304353051 -304353051 -377871112 -304353051 -304353051 -272305922 -304353051 -304353051 -312837974 -304353051 -304353051 -286767621 -304353051 -304353051 -304353051 -286767621 -286767621 -272305922 -286767621 -272305922 -272305922 -272305922 -272305922 -183863704 -183863704 -158135404 -158135404 -135471326 -135471326 -135471326 -135471326 -135471326 -135471326 -103675844 -103675844 -49281337 -49281337 -25555744 -49281337 -25555744 -25555744 -25555744 -49281337 -25555744 -49281337 -25555744 -25555744 -24345264 -25555744 -24345264 -24345264 -24345264 -25555744 -24345…

Example 2:

Input: 3258 563216903 -880249639 -952713130 240312615 116203092 -145558712 430013896 -142503634 -712079397 850656998 -602785619 -596800304 664709935 -216463587 278663365 310910999 575229692 133524480 -244257167 872609278 -353548242 -936742917 289391066 -788436544 -99019230 -907152496 -988284881 -199556780 -899759441 286121850 793673489 706197591 -822062383 947726212 -288030373 -787920907 262324074 8578218 309838569 -705591604 -562761385 755765190 431783131 808718778 947206955 -689126365 -999660654 -335289594 764807322 -685848109 -233955147 361167695 -997013881 -791718952 -248495699 -221526593 -626644429 635147282 590991980 495010268 127833527 -965985470 358954789 -193655135 744734076 -537008263 536900646 -934636163 80151819 924096553 -816063657 100422004 803694132 652386169 160210288 -356271416 -…
Output: 563216903 -880249639 -880249639 -880249639 116203092 -145558712 116203092 -142503634 -142503634 -142503634 -142503634 -145558712 -142503634 -145558712 -142503634 -142503634 116203092 116203092 116203092 116203092 116203092 -142503634 116203092 -142503634 -99019230 -142503634 -142503634 -145558712 -145558712 -145558712 -142503634 -142503634 -142503634 -142503634 -142503634 -145558712 -142503634 -142503634 -99019230 -142503634 -142503634 -142503634 -99019230 -99019230 8578218 -99019230 -99019230 -142503634 -99019230 -142503634 -142503634 -142503634 -142503634 -145558712 -145558712 -199556780 -199556780 -199556780 -145558712 -145558712 -142503634 -145558712 -142503634 -145558712 -142503634 -145558712 -142503634 -145558712 -142503634 -142503634 -142503634 -142503634 -99019230 -99019230 8578218…

Example 3:

Input: 3624 -412513862 -185479560 -738530173 217909610 -648543395 152888059 -556249505 918376796 683681718 -685345735 52041313 -500343672 339277233 -101752242 -637552882 633862146 -584911573 -30283808 775699658 582595223 878490550 39101059 -624272643 -240175097 -502819968 -219970932 407836379 677892818 795199181 964512558 709097913 -817294002 -773671792 361295583 -276178385 8073888 -453690893 729414983 -262000985 -451335045 328352822 713125201 691580250 273711927 727983763 -330104287 823964973 -789797278 58544544 381386776 149210511 270200862 -248731532 481736332 -197111471 -789814847 222541770 656725820 952476935 566920770 -429907420 -999750306 -187643792 -199150280 799317190 270612480 -738220641 299376837 651015970 -93173586 -726177659 563468984 -684717795 -197075515 -826418087 883275594 834358…
Output: -412513862 -412513862 -412513862 -412513862 -412513862 -412513862 -412513862 -412513862 -185479560 -412513862 -185479560 -412513862 -185479560 -185479560 -185479560 -185479560 -185479560 -185479560 -101752242 -101752242 -30283808 -30283808 -30283808 -101752242 -101752242 -185479560 -101752242 -101752242 -30283808 -30283808 39101059 -30283808 -30283808 -30283808 -30283808 -30283808 -30283808 -30283808 -30283808 -101752242 -30283808 -30283808 8073888 8073888 39101059 8073888 39101059 8073888 39101059 39101059 52041313 52041313 52041313 52041313 52041313 39101059 52041313 52041313 58544544 58544544 58544544 52041313 52041313 39101059 52041313 52041313 52041313 52041313 58544544 52041313 52041313 52041313 52041313 39101059 39101059 39101059 52041313 52041313 58544544 52041313 52041313 39101059…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.