CT65106

Last registers of Cora

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the ribbon falls of Cascade Vale. Cora spreads the registers records across the table and picks up a sharp pencil. 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: 695 213395124 276454673 876727987 -164349494 -17496318 652125424 -926989677 -990262265 -53102810 -225697445 394485885 -156057279 905734275 411529377 123773040 -550641505 -255609848 1943459 -535915995 -539664390 -216258301 471788904 -64916168 -632737310 -330740543 636327082 -242045456 -430879502 -751300196 -182577004 -285859784 -905773590 -139653180 217476462 -379122730 -349832538 -515118841 146262239 401732074 -885614167 289387838 941951830 -816235971 958611264 -714545735 974936914 882165741 -21752330 831842185 -308754633 -21182845 650483524 -605463860 139725685 -777570480 252101999 300555714 -794105355 591233419 29586937 -182306246 -281718687 -687644861 180831078 -515180338 -43251025 -935604570 301941425 -12445532 -516895971 211656447 730478898 -646354889 631255722 928531547 -352672857 -2…
Output: 213395124 213395124 276454673 213395124 213395124 213395124 213395124 -17496318 -17496318 -53102810 -17496318 -53102810 -17496318 -17496318 123773040 -17496318 -17496318 -17496318 -17496318 -53102810 -53102810 -53102810 -53102810 -64916168 -64916168 -64916168 -64916168 -156057279 -156057279 -164349494 -164349494 -182577004 -164349494 -164349494 -164349494 -182577004 -182577004 -182577004 -164349494 -182577004 -164349494 -164349494 -164349494 -164349494 -164349494 -164349494 -156057279 -156057279 -139653180 -156057279 -139653180 -139653180 -139653180 -139653180 -139653180 -139653180 -64916168 -139653180 -64916168 -64916168 -64916168 -139653180 -139653180 -139653180 -139653180 -139653180 -139653180 -139653180 -64916168 -139653180 -64916168 -64916168 -64916168 -64916168 -53102810 -64916168 -6…

Example 2:

Input: 3121 895060701 673224745 -331187278 603580198 413002313 145946792 -949538849 -731452801 -954097750 -302037684 -368175695 -468879160 405277581 220912764 293420304 763453226 532881234 275212054 -672773921 890200230 -814174387 256918752 -266881627 -213864298 -952894535 666166119 -523917808 179455669 96038383 -822082731 330188446 -581961346 -474697363 -375933155 114881269 565509949 602616329 -826222094 -813937716 51144154 -768269802 571562583 -422224583 -271976938 -975009998 -315159954 -725287213 -924400692 433695438 801302003 279151229 563803150 16687428 -286211709 947000269 186175985 -696012464 941074524 518252843 246029592 46840960 -426515628 167108403 -377006139 -667583736 -690763828 170221444 -239622224 678295294 102289848 -806201436 -795966598 286683105 -189432370 876200517 -934040037 86…
Output: 895060701 673224745 673224745 603580198 603580198 413002313 413002313 145946792 145946792 -302037684 -302037684 -331187278 -302037684 -302037684 145946792 145946792 220912764 220912764 220912764 220912764 220912764 220912764 220912764 145946792 145946792 145946792 145946792 145946792 145946792 96038383 145946792 96038383 96038383 -213864298 96038383 96038383 114881269 96038383 96038383 51144154 51144154 51144154 51144154 -213864298 -213864298 -266881627 -266881627 -271976938 -266881627 -266881627 -213864298 -213864298 16687428 -213864298 16687428 16687428 16687428 16687428 51144154 51144154 51144154 46840960 51144154 46840960 46840960 16687428 46840960 16687428 46840960 46840960 46840960 16687428 46840960 16687428 46840960 16687428 46840960 16687428 16687428 16687428 46840960 16687428 4684…

Example 3:

Input: 598 -739288475 831198851 731423768 724126659 -291342541 -908309846 -924744837 961053323 497739520 -575733601 -79206633 292227583 -549848605 -660837101 -16799162 248748739 807057653 372052221 543709699 623758217 -809107698 -757876279 -994159191 856404263 561208374 873197687 316605335 731717784 877601363 -627425425 -208426783 966926568 376144937 -701138334 530759584 149474108 -844855874 687685555 -278768665 -269982593 -109176682 847116092 -21465792 669613749 896097524 -549961332 961491627 -689622674 78740924 -936261284 -496172207 437424215 300643265 953810075 866061284 866332186 -299501568 979772635 239921860 -638100206 78206351 -240483226 324219421 -615746626 109370021 -759153697 -39857473 -562275386 -822683863 -585836224 -271142746 -262981490 -682305829 597843456 -442859800 976522776 -8647…
Output: -739288475 -739288475 731423768 724126659 724126659 -291342541 -291342541 -291342541 497739520 -291342541 -79206633 -79206633 -79206633 -291342541 -79206633 -79206633 -16799162 -16799162 248748739 248748739 248748739 -16799162 -16799162 -16799162 248748739 248748739 292227583 292227583 316605335 292227583 292227583 292227583 316605335 292227583 316605335 292227583 292227583 292227583 292227583 248748739 248748739 248748739 248748739 248748739 292227583 248748739 292227583 248748739 248748739 149474108 149474108 149474108 248748739 248748739 292227583 292227583 292227583 292227583 292227583 248748739 248748739 239921860 248748739 239921860 239921860 149474108 149474108 109370021 109370021 78740924 78740924 78206351 78206351 78206351 78206351 78206351 78206351 78206351 78740924 78206351 7820…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last registers of Cora - MEDIUM Coding Problem | CodeTikki