CT58853

The Middle So Far Beneath Starfall

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the observatory of Starfall, Varun studies rows of beacons entries. One clean number will settle the guild's oldest argument. 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: 3384 -181241882 999013714 -128416896 835790951 132537141 -831488430 -616299990 -329589812 -960240430 -426168749 105450526 657960766 693205849 123701889 -120012809 -492570376 250459022 -632948392 792418786 214904341 760035993 59822639 -723600870 -672915326 947312397 -640750677 -698073845 -205551322 -745927653 -842208171 -374183431 -46877438 -668166264 109974857 586142681 961713834 889742054 -923140241 -317094480 -546768797 -430941378 -966957200 123893431 953538161 -886346327 -324329091 616027187 -29942893 -208596443 989426457 -708769721 184413316 -944627527 -136591602 -77779347 432542376 -30994647 -877967109 -834592400 332659072 -491939310 821511281 303590873 956597232 -776784804 208112549 -428394141 184144874 -446757625 112877218 -628170808 453390151 792111194 896912015 -75050568 875302936…
Output: -181241882 -181241882 -128416896 -128416896 132537141 -128416896 -128416896 -181241882 -181241882 -329589812 -181241882 -181241882 -128416896 -128416896 -120012809 -128416896 -120012809 -128416896 -120012809 -120012809 105450526 59822639 59822639 -120012809 59822639 -120012809 -120012809 -128416896 -128416896 -181241882 -181241882 -181241882 -181241882 -181241882 -128416896 -128416896 -120012809 -128416896 -128416896 -181241882 -181241882 -205551322 -181241882 -181241882 -181241882 -205551322 -181241882 -181241882 -181241882 -181241882 -181241882 -181241882 -181241882 -181241882 -136591602 -136591602 -128416896 -136591602 -136591602 -136591602 -136591602 -136591602 -128416896 -128416896 -128416896 -128416896 -128416896 -128416896 -128416896 -128416896 -128416896 -128416896 -120012809 -1200…

Example 2:

Input: 196 -721542140 -965147991 -406645489 613620140 551467858 -305150347 75025317 -531427180 569815105 414285505 612248771 495132003 -5277961 815727536 945447166 876117290 -667826078 176468314 -878023538 254809309 -246698144 -144790963 418700346 -226852847 -905532026 -321081968 334942392 -362438379 297253924 737909505 319202060 -593967523 -136797346 740056032 29300945 -664261587 619067036 2709644 2388244 96625056 480753624 -369051302 351814551 -942811789 785730491 219758175 913516514 588697879 -740544991 -631417873 -955496459 319893387 -253957287 764774938 799979753 371062416 840349555 759086741 -657158041 110136092 -781492916 85109040 374794085 931327460 256353386 -771340391 868425065 152208832 -704395627 977494137 -693171893 -882930653 -146743237 823425599 -846409891 909535200 -808191358 -513…
Output: -721542140 -965147991 -721542140 -721542140 -406645489 -406645489 -305150347 -406645489 -305150347 -305150347 75025317 75025317 75025317 75025317 414285505 414285505 414285505 176468314 176468314 176468314 176468314 75025317 176468314 75025317 75025317 -5277961 75025317 -5277961 75025317 75025317 176468314 75025317 75025317 75025317 75025317 29300945 75025317 29300945 29300945 29300945 75025317 29300945 75025317 29300945 75025317 75025317 96625056 96625056 96625056 75025317 75025317 75025317 75025317 75025317 96625056 96625056 176468314 176468314 176468314 110136092 110136092 96625056 110136092 110136092 176468314 110136092 176468314 152208832 152208832 152208832 152208832 110136092 110136092 110136092 110136092 110136092 110136092 96625056 96625056 85109040 85109040 85109040 85109040 8510…

Example 3:

Input: 2086 975307486 -707048635 158051791 -789875029 -233036653 115852033 -84260642 422303457 357991874 -828858145 -273866533 -243759136 469753830 -869758909 728970253 -734823566 114870766 875651705 80154442 -504737645 85737778 -908460856 -880884730 199902280 137545992 -481879455 989370593 692897417 217975032 -96786596 -625125896 252751459 -697732979 937841574 -708614894 908211091 331576364 -943558699 -464074592 353520604 -472770584 89441831 -531597443 -792224957 -518658190 530427573 -467596451 -384899186 -997834041 892296814 -821945197 -428633209 -213816575 618842156 -720384917 -951288321 -346068589 -671947667 993951569 395654735 289546509 375744254 215576145 561207822 390199472 171235812 800099145 -68786617 231147992 220952923 -763283945 -126800272 415847115 -669339528 476850960 -531039543 -82…
Output: 975307486 -707048635 158051791 -707048635 -233036653 -233036653 -84260642 -84260642 115852033 -84260642 -84260642 -233036653 -84260642 -233036653 -84260642 -233036653 -84260642 -84260642 80154442 -84260642 80154442 -84260642 -84260642 -84260642 80154442 -84260642 80154442 80154442 85737778 80154442 80154442 80154442 80154442 80154442 80154442 80154442 85737778 80154442 80154442 80154442 80154442 80154442 80154442 -84260642 -84260642 -84260642 -84260642 -96786596 -96786596 -96786596 -96786596 -233036653 -213816575 -213816575 -213816575 -233036653 -233036653 -243759136 -233036653 -233036653 -213816575 -213816575 -96786596 -96786596 -84260642 -84260642 80154442 -68786617 80154442 80154442 80154442 -68786617 80154442 -68786617 80154442 -68786617 -68786617 -68786617 80154442 80154442 85737778 8…

Constraints:

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

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