CT59838

Jasper signals Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the canyon post of Redrock, Petr studies rows of signals 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: 504 536091211 -648420022 22395989 -66231956 856061363 -701670223 487506696 711326964 -514407841 -931115336 678511724 -495042070 749488914 530854610 -378126454 -226095612 -234639996 964991223 665999008 32592470 -741572979 -965189919 -3103759 -492553705 -593680961 -400218710 607485160 -560578040 368554664 222062823 -719589081 593981937 882321755 -895711649 307547218 -248613220 -417981107 33790356 308934555 -439934041 -740983604 -976067955 -115325622 -760218485 329605179 240785965 -682798756 -970243596 -99840601 149982477 315827540 819671444 -999268836 -940452006 8122604 -331602740 -985434327 798390696 -417433959 923356287 -577493292 90407234 121401325 -697165429 250746449 -974666772 -718184894 451583648 443450235 -739578215 520954946 -706167349 -62232338 -293900385 -69005904 -548744641 18961…
Output: 536091211 -648420022 22395989 -66231956 22395989 -66231956 22395989 22395989 22395989 -66231956 22395989 -66231956 22395989 22395989 22395989 -66231956 -66231956 -66231956 22395989 22395989 22395989 -66231956 -3103759 -66231956 -66231956 -226095612 -66231956 -226095612 -66231956 -66231956 -66231956 -66231956 -3103759 -66231956 -3103759 -66231956 -66231956 -66231956 -3103759 -66231956 -66231956 -226095612 -115325622 -226095612 -115325622 -115325622 -115325622 -226095612 -115325622 -115325622 -99840601 -99840601 -99840601 -115325622 -99840601 -115325622 -115325622 -115325622 -115325622 -115325622 -115325622 -115325622 -99840601 -115325622 -99840601 -115325622 -115325622 -115325622 -99840601 -115325622 -99840601 -115325622 -99840601 -115325622 -99840601 -115325622 -99840601 -115325622 -998406…

Example 2:

Input: 8 -350224491 -804131443 -208991224 904756975 437807779 422480326 -293102988 -618448274
Output: -350224491 -804131443 -350224491 -350224491 -208991224 -208991224 -208991224 -293102988

Example 3:

Input: 2889 -990668651 -317830507 925748066 508790437 -64095123 -191274266 -12601845 416670901 882769365 -978513141 196154058 667396614 -732095037 -73198331 105825260 -440559944 -204030866 897570173 612891080 -771929125 -312635364 -933914918 -895366415 -216979615 -184943361 245745570 230816085 465243593 -423390270 -692766972 250555769 -661123942 -890622976 969028705 515008179 -706269925 267291122 -598958815 648796636 -162133942 392900226 -96272824 170285252 -797158540 42295809 -178736511 -186724587 -405699338 854081243 41586466 -243008492 -674510086 -23740688 752543914 269603955 734714794 -775310581 69391527 -708476079 599832606 -306127037 -684522013 858760167 985408188 -249611022 53896443 674231624 -566156344 -934333345 -883383886 -597620667 775811220 -809483895 269131495 823289563 167249649 474…
Output: -990668651 -990668651 -317830507 -317830507 -64095123 -191274266 -64095123 -64095123 -12601845 -64095123 -12601845 -12601845 -12601845 -64095123 -12601845 -64095123 -64095123 -64095123 -12601845 -64095123 -64095123 -73198331 -73198331 -191274266 -184943361 -184943361 -73198331 -73198331 -73198331 -184943361 -73198331 -184943361 -184943361 -184943361 -73198331 -184943361 -73198331 -184943361 -73198331 -162133942 -73198331 -96272824 -73198331 -96272824 -73198331 -96272824 -96272824 -162133942 -96272824 -96272824 -96272824 -162133942 -96272824 -96272824 -73198331 -73198331 -73198331 -73198331 -73198331 -73198331 -73198331 -96272824 -73198331 -73198331 -73198331 -73198331 -64095123 -73198331 -73198331 -96272824 -96272824 -96272824 -96272824 -96272824 -73198331 -73198331 -64095123 -64095123 -23…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jasper signals Middle So Far - MEDIUM Coding Problem | CodeTikki