CT58609

The Pale Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Koda runs the gallery at the temple city of Sunspire. Today the books show a list of beacons, 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: 1237 -426418794 -481053955 -477356142 -101972123 277738543 -623138296 -409215071 222384528 439847047 708197822 -722160849 -286360075 -113751604 569794095 -386137336 546369849 -561177503 -787934995 388895771 -352560719 52933590 -961498972 237824796 -779917177 277431847 118362404 997556349 -646400501 -221885514 429175830 796363382 836566986 -289746551 -742996306 -617783791 -171757819 -414342996 -113688957 814260916 456730415 -940485053 -877218755 -430015823 -403255467 -726535876 -895327926 893321746 -245055561 -357015971 -602195603 951289746 863295596 306298743 -943922770 -458517090 346891128 122876267 -582195942 -139482262 -140414402 945723503 -737056010 -262742306 211245743 -446313305 707142742 599516624 62629133 -688754338 136223411 236346314 -105126204 -6926099 -584611616 691410506 60419…
Output: -426418794 -481053955 -477356142 -477356142 -426418794 -477356142 -426418794 -426418794 -409215071 -409215071 -409215071 -409215071 -286360075 -286360075 -286360075 -286360075 -286360075 -386137336 -286360075 -352560719 -286360075 -352560719 -286360075 -352560719 -286360075 -286360075 -113751604 -286360075 -221885514 -221885514 -113751604 -113751604 -113751604 -221885514 -221885514 -221885514 -221885514 -221885514 -171757819 -171757819 -171757819 -221885514 -221885514 -286360075 -286360075 -289746551 -286360075 -286360075 -286360075 -289746551 -286360075 -286360075 -245055561 -286360075 -286360075 -286360075 -245055561 -286360075 -245055561 -245055561 -221885514 -245055561 -245055561 -245055561 -245055561 -245055561 -221885514 -221885514 -221885514 -221885514 -171757819 -171757819 -1404144…

Example 2:

Input: 3722 6971463 -163085590 -727139285 -341687685 -361102698 -166409665 -97287330 -590190083 -434228261 150808526 -864783388 823463869 824679065 -990347695 -271510997 601830364 -526006729 296137159 536313416 -906810768 -643151070 534697278 -726003903 -604830405 -522825619 -217271015 -968010011 -988474594 -671619522 -622619368 392782024 -540594005 -33929510 430595356 -978066634 488265978 468522408 766999391 -413169365 -122493359 296848431 -614452777 235980978 -16978937 -29810632 320390315 422325597 169049244 -199848220 -141449433 -862109666 380782755 210331486 -703558961 95029892 758820126 371681218 -380906646 -177337158 886248956 -704964985 -767470984 -774777798 803584960 -739193069 -662592570 -79674078 -161155315 747160822 -135032819 257606647 -143683075 76732035 -384255664 833986524 40641305…
Output: 6971463 -163085590 -163085590 -341687685 -341687685 -341687685 -166409665 -341687685 -341687685 -341687685 -341687685 -341687685 -166409665 -341687685 -271510997 -271510997 -271510997 -271510997 -166409665 -271510997 -271510997 -271510997 -271510997 -341687685 -341687685 -341687685 -341687685 -361102698 -361102698 -434228261 -361102698 -434228261 -361102698 -361102698 -361102698 -361102698 -341687685 -341687685 -341687685 -341687685 -271510997 -341687685 -271510997 -271510997 -217271015 -217271015 -166409665 -166409665 -166409665 -166409665 -166409665 -166409665 -163085590 -166409665 -163085590 -163085590 -141449433 -163085590 -163085590 -163085590 -163085590 -166409665 -166409665 -166409665 -166409665 -177337158 -166409665 -166409665 -163085590 -163085590 -161155315 -161155315 -143683075 …

Example 3:

Input: 163 -91189942 -292757927 -165539807 337366812 214744206 333237718 714166873 -21781518 -17856952 -608989620 -545872014 -827414953 -974794748 344082397 -951840626 930269843 -660470369 300644032 -975357449 671795500 -251575869 -87115720 570611979 -603048278 968712499 -810559869 -471094285 366499437 468404637 -150936118 -414729379 -150794244 612291284 435084830 374797361 585063695 -983080047 -19277826 517846312 891535951 242623202 -841011201 759128411 454939310 -87518261 -768830985 -646116043 -861045371 945502318 -365537604 611987139 436327064 376316063 -547671601 947822201 -868937871 207613631 -144416882 132335437 -231327342 -408454880 -703796792 -505944829 675382777 -216773738 -320389864 455435640 807017668 -888823007 382711208 254648792 -285599460 -890089914 18629284 154999755 685972585 -21…
Output: -91189942 -292757927 -165539807 -165539807 -91189942 -91189942 214744206 -21781518 -17856952 -21781518 -21781518 -91189942 -91189942 -91189942 -91189942 -91189942 -91189942 -91189942 -91189942 -91189942 -91189942 -91189942 -87115720 -91189942 -87115720 -91189942 -91189942 -91189942 -87115720 -91189942 -91189942 -150794244 -91189942 -91189942 -87115720 -87115720 -87115720 -87115720 -21781518 -21781518 -19277826 -21781518 -19277826 -19277826 -19277826 -21781518 -21781518 -87115720 -21781518 -87115720 -21781518 -21781518 -19277826 -21781518 -19277826 -21781518 -19277826 -21781518 -19277826 -21781518 -21781518 -87115720 -87115720 -87115720 -87115720 -87518261 -87115720 -87115720 -87115720 -87115720 -21781518 -87115720 -87115720 -87115720 -21781518 -21781518 -21781518 -87115720 -87115720 -87518…

Constraints:

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

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