CT61597

The registers at Galeholm

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the zephyr cliffs of Galeholm close for winter, Nyssa must finish the registers 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: 3163 -678363697 -859475110 137050172 -389998027 -192711302 964728670 -775101715 -162554322 -654988221 200225124 -398459393 -173189068 716752252 211343685 80051887 -119373052 -560072337 131498003 462451401 -773903650 -370944318 -87821932 302256542 -100870290 -520437494 -350566810 837374677 -860179038 660757948 -486933960 900864152 564930699 502358039 476402330 828523772 996575308 -950598306 999353502 -558260777 271413835 -194010586 -723092904 -494669265 946010863 -357944418 302741587 -37515670 43497985 -227864775 269920120 -993040179 -949113443 -165950149 -486015655 47582974 -255676032 591025711 302476232 -526397797 -587035057 382426731 871970106 750840539 -958346999 -408522824 -468626869 280521735 -532547486 668545613 -219917644 -194643386 -967838870 -374939419 -305396423 -976345483 473068…
Output: -678363697 -859475110 -678363697 -678363697 -389998027 -389998027 -389998027 -389998027 -389998027 -389998027 -389998027 -389998027 -192711302 -192711302 -173189068 -173189068 -173189068 -173189068 -162554322 -173189068 -173189068 -173189068 -162554322 -162554322 -162554322 -173189068 -162554322 -173189068 -162554322 -173189068 -162554322 -162554322 -119373052 -119373052 -100870290 -100870290 -100870290 -100870290 -100870290 -100870290 -100870290 -119373052 -119373052 -119373052 -119373052 -119373052 -100870290 -100870290 -100870290 -100870290 -100870290 -119373052 -119373052 -162554322 -119373052 -162554322 -119373052 -119373052 -119373052 -162554322 -119373052 -119373052 -100870290 -119373052 -119373052 -162554322 -119373052 -162554322 -119373052 -162554322 -162554322 -165950149 -1659501…

Example 2:

Input: 1975 -621729115 -378799747 -479571420 134292710 -283709425 704698953 -438121860 70514106 884511134 -676584976 -891329317 -60331936 -764188692 701747622 59121814 379984499 368151595 836965822 425711617 798264604 -116174937 96625488 684334914 -62187640 -570616311 411873785 582126127 994837130 720935124 264008668 775037643 -296380860 819696146 629174285 351863045 -659768005 -921933688 -147106410 679744835 -237806413 738005565 531516068 -357696220 -270283561 -749123470 664308371 -329941499 -671064124 -970113577 860169354 -233912683 151221532 -996209202 812534224 94264740 267361917 -696339073 -375221910 299173675 -535404751 -401874266 -927511959 -491156574 -271961092 396646296 -654950599 509393039 -724339794 -617649839 820914654 404975718 -633142902 19389171 -728846432 -73072146 -148469090 -123…
Output: -621729115 -621729115 -479571420 -479571420 -378799747 -378799747 -378799747 -378799747 -283709425 -378799747 -378799747 -378799747 -378799747 -378799747 -283709425 -283709425 -60331936 -60331936 59121814 59121814 59121814 59121814 70514106 59121814 59121814 59121814 70514106 70514106 96625488 96625488 134292710 96625488 134292710 134292710 264008668 134292710 134292710 96625488 134292710 96625488 134292710 134292710 134292710 96625488 96625488 96625488 96625488 70514106 70514106 70514106 70514106 70514106 70514106 70514106 94264740 94264740 94264740 70514106 94264740 70514106 70514106 59121814 59121814 -60331936 59121814 -60331936 59121814 -60331936 -60331936 -60331936 59121814 -60331936 19389171 -60331936 -60331936 -62187640 -62187640 -62187640 -60331936 -60331936 -60331936 -60331936 193…

Example 3:

Input: 2407 323318987 193994034 59128334 -481748247 -561952726 880155840 -145816739 -458548476 -95153120 -36191074 -170804544 -690071050 -203211130 690551501 -870156223 586973219 722964582 606107052 -442866538 328173182 -310786726 -672552341 -205656528 -501713192 -635477713 -744076525 316018965 -412904544 442943025 340026411 -135733869 920940425 242143341 128170970 442544812 -653021878 71077092 -171063332 -241117760 128434171 -167894013 -418783131 -917066991 74106177 -482105521 321023808 -345065194 638426649 -766425644 -946907256 601877752 -858361103 768622989 138811039 686566703 191712039 -340128373 -276221200 -204831563 15257181 759140870 -143653854 300729846 -768764556 248984908 -591185069 -258494304 -625513528 706569516 203771219 -722293229 -61710660 176279442 800524407 -129487319 -362456220 …
Output: 323318987 193994034 193994034 59128334 59128334 59128334 59128334 -145816739 -95153120 -95153120 -95153120 -145816739 -145816739 -145816739 -145816739 -145816739 -95153120 -95153120 -95153120 -95153120 -95153120 -145816739 -145816739 -170804544 -170804544 -203211130 -170804544 -203211130 -170804544 -170804544 -145816739 -145816739 -135733869 -135733869 -95153120 -135733869 -95153120 -135733869 -135733869 -135733869 -135733869 -145816739 -145816739 -145816739 -145816739 -145816739 -145816739 -145816739 -145816739 -167894013 -145816739 -167894013 -145816739 -145816739 -135733869 -135733869 -135733869 -145816739 -145816739 -145816739 -135733869 -143653854 -135733869 -143653854 -135733869 -143653854 -143653854 -145816739 -143653854 -143653854 -143653854 -143653854 -135733869 -135733869 -129487…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The registers at Galeholm - MEDIUM Coding Problem | CodeTikki