CT65143

Xavi's Secret Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the cork grove of Barkhaven close for winter, Xavi must finish the ledgers ledger - one figure at a time. 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: 1938 935487352 342786509 727485071 -834429368 -833267613 653932676 -975528303 -113610860 -709683272 -902664312 386931151 621870589 505706012 -236816834 -483207083 -846441871 -375806662 -514202276 128257693 -755132378 440642822 791002105 975553272 642178896 882055627 -729332121 -714334986 -50350927 884746579 374897674 -800264172 42970829 -996701562 -651467380 -884365498 -227771930 214578604 129789858 -947262263 -936472409 -57866203 699048193 698698037 964836993 97435196 560028529 37813917 525990727 -763236324 899496889 573400287 -872035024 66135662 489305596 -192987123 -771326168 -233437666 -743479696 -940914424 -308810324 795083239 116886402 49687491 399087479 952416853 18460256 -907894492 944320550 -164978521 891277199 576807760 146455753 760814447 -367091933 812577271 107271623 -80608314…
Output: 935487352 342786509 727485071 342786509 342786509 342786509 342786509 -113610860 -113610860 -709683272 -113610860 -113610860 342786509 -113610860 -113610860 -236816834 -236816834 -375806662 -236816834 -375806662 -236816834 -236816834 -113610860 -113610860 128257693 -113610860 -113610860 -113610860 -50350927 -50350927 -50350927 -50350927 -50350927 -113610860 -113610860 -227771930 -113610860 -113610860 -113610860 -227771930 -113610860 -113610860 -57866203 -57866203 -50350927 -50350927 37813917 37813917 37813917 37813917 42970829 37813917 42970829 42970829 42970829 37813917 37813917 -50350927 -50350927 -57866203 -50350927 -50350927 37813917 37813917 42970829 37813917 37813917 37813917 37813917 37813917 42970829 42970829 49687491 42970829 49687491 49687491 49687491 49687491 49687491 49687491 4…

Example 2:

Input: 3259 264760069 88673497 -366650065 416787675 409913447 -392260192 -243212924 147604057 394319892 646950862 -117352260 -768062771 -818042590 872654733 -245373386 -469967227 464874108 887327741 40219761 228027626 -618541222 -503356114 135864522 -857094783 943780231 620232063 -74597060 818138439 -823929721 -209565822 -650050410 223649742 150444342 -860636085 623209903 342582612 -40298149 -251550241 -81931605 -859257802 248212568 61936880 -311013704 826825617 -350634532 -359766230 890629386 -973006160 -278643444 506058386 -936234912 -409103190 -161314579 42652862 99001761 -667795894 167981792 690193760 799546476 -352034833 -205711154 -22098595 -45265510 -721573043 583538422 -600822749 712168593 288183743 -533798055 -67293063 146161063 426399805 -839156216 -306300951 -881546563 -332178494 -1041…
Output: 264760069 88673497 88673497 88673497 264760069 88673497 88673497 88673497 147604057 147604057 147604057 88673497 88673497 88673497 88673497 -117352260 88673497 88673497 88673497 88673497 88673497 40219761 88673497 40219761 88673497 88673497 88673497 88673497 88673497 40219761 40219761 40219761 88673497 40219761 88673497 88673497 88673497 40219761 40219761 -40298149 40219761 40219761 40219761 40219761 40219761 -40298149 40219761 -40298149 -40298149 -40298149 -40298149 -74597060 -74597060 -74597060 -40298149 -74597060 -40298149 -40298149 40219761 -40298149 -40298149 -40298149 -40298149 -45265510 -40298149 -45265510 -40298149 -40298149 -40298149 -45265510 -40298149 -40298149 -40298149 -45265510 -45265510 -67293063 -67293063 -67293063 -67293063 -74597060 -67293063 -67293063 -67293063 -74597060…

Example 3:

Input: 1787 365570011 -446147701 205858720 -304534363 452522170 916205163 -592936105 430368396 -176774612 877503424 791382044 1174897 386043298 520876246 -99772413 337312274 -657391943 745286451 937551003 466851262 420421021 -244851684 -474041629 -306701920 -128721306 108825704 -696425509 131309864 694625313 -539891637 -504807786 -992741457 837943051 -654437397 591531220 -485022855 90379081 -757432104 -189095917 549866113 -626001929 678312251 941524023 700929697 37316305 -924114561 760096795 965053673 -845844886 -835101831 -705879772 718968104 671073812 -197882289 599895596 -531165458 833720915 894734305 498744423 852123013 -960416610 849912275 65047061 204538603 -747004705 -833965459 206245633 53694644 735865653 340311753 530834328 133488942 -25401705 -365792505 948464307 531821388 236823402 669…
Output: 365570011 -446147701 205858720 -304534363 205858720 205858720 205858720 205858720 205858720 205858720 365570011 205858720 365570011 365570011 365570011 337312274 337312274 337312274 365570011 365570011 386043298 365570011 365570011 337312274 337312274 205858720 205858720 131309864 205858720 131309864 131309864 108825704 131309864 108825704 131309864 108825704 108825704 90379081 90379081 90379081 90379081 90379081 108825704 108825704 108825704 90379081 108825704 108825704 108825704 90379081 90379081 90379081 108825704 90379081 108825704 90379081 108825704 108825704 131309864 131309864 131309864 131309864 131309864 131309864 131309864 108825704 131309864 108825704 131309864 131309864 204538603 133488942 133488942 131309864 133488942 133488942 204538603 204538603 204538603 204538603 204538603…

Constraints:

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

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