CT63386

Paige's registers Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Paige runs the aviary at the rook towers of Chessfield. Today the books show a list of registers, and the numbers must be worked out before sundown. 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: 1218 377818367 -853782898 690401664 962617211 -544642688 -109646779 -796045237 391571600 -761175898 570369063 824790713 115154481 802283016 201613114 53355857 -127240772 429627354 -505524962 -945504242 -725344401 -449996280 -368032718 -480934501 114355228 887913541 -656388928 240426402 -16676163 -503451270 730909632 -501706081 234542744 749401243 -152737868 949580117 613287466 575216001 694249386 -449600731 -349091684 -978357247 15569743 -347533068 318371615 191583434 365705298 631798451 221519898 -557496758 -46698117 417741835 247691544 -792179469 -539217102 272810189 431464243 -74106631 -940701826 -703479773 -896675199 -47220978 609607353 -614761321 237108914 951300417 -272430816 953881548 -820881603 -524205916 468435770 -801729931 222757206 179647406 -44357152 975238259 914784170 -25082…
Output: 377818367 -853782898 377818367 377818367 377818367 -109646779 -109646779 -109646779 -109646779 -109646779 377818367 115154481 377818367 201613114 201613114 115154481 201613114 115154481 115154481 53355857 53355857 -109646779 -109646779 -109646779 53355857 -109646779 53355857 -16676163 -16676163 -16676163 -16676163 -16676163 53355857 -16676163 53355857 53355857 114355228 114355228 114355228 53355857 53355857 15569743 15569743 15569743 53355857 53355857 114355228 114355228 114355228 53355857 114355228 114355228 114355228 53355857 114355228 114355228 114355228 53355857 53355857 15569743 15569743 15569743 15569743 15569743 53355857 15569743 53355857 15569743 15569743 15569743 15569743 15569743 53355857 15569743 53355857 53355857 53355857 53355857 53355857 53355857 114355228 53355857 53355857 1…

Example 2:

Input: 2941 956523420 414357805 -39052410 841339742 -233785974 -915275764 890434449 -467174252 613793127 -300716933 -942401097 321067030 -879360706 634488947 129071782 235330909 -533209509 653418333 90817674 -993828393 -597862047 284679334 -4818333 -378069481 -45271442 280430754 -980153563 -318030645 -823572462 -476840088 607488089 -399172641 -40383042 -514736135 -809066769 669974455 -860802404 -900824204 -970199809 373962456 738229577 -474775728 235817699 -414798939 -844641732 -359916565 794198470 -678607542 254603308 282826160 289836429 -596671278 -664102450 -879684294 756923580 589656983 182276067 -453207117 845725302 -911439928 680004488 -534568546 616605356 777854608 -878120530 -800991576 -480653594 -865448825 224184140 793606766 647042434 -488476245 -953457131 -200339356 876248420 -22941744…
Output: 956523420 414357805 414357805 414357805 414357805 -39052410 414357805 -39052410 414357805 -39052410 -39052410 -39052410 -39052410 -39052410 129071782 129071782 129071782 129071782 129071782 90817674 90817674 90817674 90817674 -4818333 -4818333 -4818333 -4818333 -39052410 -39052410 -45271442 -39052410 -45271442 -40383042 -45271442 -45271442 -45271442 -45271442 -233785974 -233785974 -233785974 -45271442 -233785974 -45271442 -233785974 -233785974 -300716933 -233785974 -300716933 -233785974 -233785974 -45271442 -233785974 -233785974 -300716933 -233785974 -233785974 -45271442 -233785974 -45271442 -233785974 -45271442 -233785974 -45271442 -45271442 -45271442 -233785974 -233785974 -300716933 -233785974 -233785974 -45271442 -233785974 -233785974 -233785974 -200339356 -229417441 -229417441 -2337859…

Example 3:

Input: 2515 -599568800 406665349 734073940 -861657551 -52670575 -696032468 -748611146 -891197000 528417022 -78758177 958244710 532432919 -693031321 608701025 -111266654 -518292376 49037772 239140731 632085026 -437670340 412240906 -380439151 40687046 708672603 -647092470 -845027882 873644531 414034811 493591439 171313248 -523864007 -614361711 249303749 78337507 738138165 -720656531 -297891279 -426675364 707381239 -281070631 708902322 -188702283 369189324 -623029441 -506175771 -821834669 -664102080 90579108 -33070851 -888523604 -656729656 -432077282 -543404013 -578674138 837800990 -480778631 623925764 880214817 -244935863 378966197 -884127760 101219341 -125497553 -405114588 -392347846 315025561 -412477977 -145910514 755323598 -759725618 281803475 -36573807 522965910 -47663355 -582557043 584518543 7…
Output: -599568800 -599568800 406665349 -599568800 -52670575 -599568800 -599568800 -696032468 -599568800 -599568800 -78758177 -78758177 -78758177 -78758177 -78758177 -111266654 -78758177 -78758177 -52670575 -78758177 -52670575 -78758177 -52670575 -52670575 -52670575 -78758177 -52670575 -52670575 40687046 40687046 40687046 -52670575 40687046 40687046 49037772 40687046 40687046 -52670575 40687046 -52670575 40687046 -52670575 40687046 -52670575 -52670575 -78758177 -78758177 -78758177 -52670575 -78758177 -78758177 -111266654 -111266654 -188702283 -111266654 -188702283 -111266654 -111266654 -111266654 -111266654 -111266654 -111266654 -111266654 -125497553 -125497553 -125497553 -125497553 -145910514 -125497553 -145910514 -125497553 -125497553 -111266654 -111266654 -111266654 -111266654 -78758177 -787581…

Constraints:

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

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