CT58035

Finn's marks Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the mountain city of Highreach, Finn studies rows of marks 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: 96 -724925800 158268934 465660404 -875971772 -553871195 329800 -456645607 -721630561 -633357705 561065203 996232355 971276795 918912009 -528111508 -825078055 430566150 -948185084 -951714568 -303171336 -872964637 -379339226 76569268 -810578021 761400842 -653410044 -982569421 -582505070 175975440 743752205 -44717092 185003273 -719302078 -203188573 160178867 350387481 -237506442 851702381 492426119 -856817560 925186644 -910403694 -608188683 995618078 -129622182 -738649403 -829041721 -353348428 -239300061 902383424 -112525349 -990701344 -14957038 -658477049 951498563 124134492 554953622 172918622 -739113466 950516296 -93438259 552359484 -832800786 -347819346 -144305024 376641971 116503819 501410653 236811082 -565487091 646664733 897974742 -759873963 -765957896 988577868 -659435270 458982176 97…
Output: -724925800 -724925800 158268934 -724925800 -553871195 -553871195 -456645607 -553871195 -553871195 -553871195 -456645607 -456645607 329800 -456645607 -456645607 -456645607 -456645607 -528111508 -456645607 -528111508 -456645607 -456645607 -456645607 -456645607 -456645607 -528111508 -528111508 -528111508 -456645607 -456645607 -379339226 -456645607 -379339226 -379339226 -303171336 -303171336 -237506442 -237506442 -237506442 -237506442 -237506442 -303171336 -237506442 -237506442 -237506442 -303171336 -303171336 -303171336 -239300061 -239300061 -239300061 -239300061 -239300061 -239300061 -237506442 -237506442 -203188573 -237506442 -203188573 -203188573 -129622182 -203188573 -203188573 -203188573 -144305024 -144305024 -129622182 -129622182 -129622182 -129622182 -112525349 -129622182 -129622182 -1…

Example 2:

Input: 941 -679831364 -857323963 497348529 203991662 882884374 -43748255 -890753286 -479577923 522787445 -683411836 -101379503 817918565 -217376398 -92328812 -391979211 547626366 -709213207 202695636 512777096 -199642487 -461647710 833375279 576367484 420153866 -947264388 573882018 796037678 718465869 558750314 -369463988 733771080 -92296986 706786895 950949784 803833521 338780236 -746088888 656191393 -54542563 141250697 399527837 -888088258 -9232460 -752379730 -595591085 -482270504 -781876088 -327511445 -165764846 -712417848 782351589 381686053 -64863625 195950488 748328765 73924246 -819205870 -683165974 -430369623 -407432325 663430853 599348757 266612255 -269154222 636426623 862577195 495344813 916895558 -570890332 243555054 37133160 -109432829 788983753 920699145 -45316731 -191593984 487306289…
Output: -679831364 -857323963 -679831364 -679831364 203991662 -43748255 -43748255 -479577923 -43748255 -479577923 -101379503 -101379503 -101379503 -101379503 -101379503 -101379503 -101379503 -101379503 -92328812 -101379503 -101379503 -101379503 -92328812 -92328812 -92328812 -92328812 -43748255 -43748255 202695636 -43748255 202695636 -43748255 202695636 202695636 203991662 203991662 203991662 203991662 203991662 202695636 203991662 202695636 202695636 141250697 141250697 -9232460 -9232460 -43748255 -43748255 -54542563 -43748255 -43748255 -43748255 -43748255 -9232460 -9232460 -9232460 -43748255 -43748255 -54542563 -43748255 -43748255 -9232460 -43748255 -9232460 -9232460 73924246 73924246 73924246 73924246 73924246 37133160 73924246 73924246 73924246 37133160 73924246 37133160 37133160 37133160 73924…

Example 3:

Input: 334 -455521893 -872094901 -139274359 420110014 196783782 -295786446 -201640316 -939906030 -913819476 524608043 880359820 979262771 -71801234 -861245079 680241162 -887169475 397086121 949219049 477910952 540002112 174217866 634576088 -988350420 -615381917 -211996346 333631731 -640588927 478809953 -844473444 49956158 928928714 152009727 159336026 -118735553 -57249913 731011436 965364046 -60096934 -717860306 -641777241 -714297458 -53417751 324681185 -507885068 757105779 -384630251 657818925 259021731 438745497 -344001144 886628635 -100969046 -390599974 177658502 552081471 341022920 420440399 -172929287 -226949940 -895889736 -928219388 167265699 658074406 675400438 -618704285 -41593647 863580571 537657222 -92569844 752396282 -13810387 -545487809 -927852793 -882775253 -955703970 -958408916 7192…
Output: -455521893 -872094901 -455521893 -455521893 -139274359 -295786446 -201640316 -295786446 -295786446 -295786446 -201640316 -201640316 -139274359 -201640316 -139274359 -201640316 -139274359 -139274359 -71801234 -71801234 174217866 174217866 174217866 -71801234 -71801234 -71801234 -71801234 -71801234 -71801234 -71801234 49956158 49956158 152009727 49956158 49956158 49956158 152009727 49956158 49956158 -57249913 -57249913 -57249913 -53417751 -57249913 -53417751 -57249913 -53417751 -53417751 49956158 -53417751 49956158 -53417751 -53417751 -53417751 49956158 49956158 152009727 49956158 49956158 -53417751 -53417751 -53417751 49956158 49956158 49956158 -41593647 49956158 49956158 49956158 49956158 49956158 -13810387 -13810387 -41593647 -41593647 -53417751 -41593647 -53417751 -41593647 -41593647 -41…

Constraints:

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

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