CT57431

The Whispering Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the granite steps of Stonehallow; Bhavi weighs the day's ledgers manifests and starts the calculations. 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: 515 -665021667 -781955036 -696433547 -252742684 -637478873 9079907 554552987 -152304407 -120909254 602168083 548891668 704012317 -800987564 186852380 -518235085 472810253 -474188473 -636728260 -203749873 282576532 -388350333 -589345534 -206547295 -148336731 124142477 -409337264 -928900640 529536047 731176169 -741000879 583955162 -212610686 -428486305 290496067 -955212414 -640068580 -980184353 -474007857 339694819 575382352 -87452257 120220821 878276819 915595127 -956110401 31253940 -369008578 -83460835 -908034050 -728914366 -543115696 233190814 -699011976 12537513 -955256398 -347989881 -808415631 409983858 551855607 926501646 547786025 892784584 -64979499 7910034 478614467 649386170 15816462 -912039121 713857432 -455003828 180899316 -855974790 77592582 -688252138 -825754756 -130936938 -434…
Output: -665021667 -781955036 -696433547 -696433547 -665021667 -665021667 -637478873 -637478873 -252742684 -252742684 -152304407 -152304407 -152304407 -152304407 -152304407 -152304407 -152304407 -252742684 -203749873 -203749873 -203749873 -252742684 -206547295 -206547295 -203749873 -206547295 -206547295 -206547295 -203749873 -206547295 -203749873 -206547295 -206547295 -206547295 -206547295 -212610686 -212610686 -252742684 -212610686 -212610686 -206547295 -206547295 -203749873 -203749873 -203749873 -203749873 -203749873 -203749873 -203749873 -206547295 -206547295 -206547295 -206547295 -206547295 -206547295 -212610686 -212610686 -212610686 -206547295 -206547295 -203749873 -203749873 -152304407 -152304407 -148336731 -148336731 -120909254 -148336731 -120909254 -148336731 -120909254 -148336731 -1209092…

Example 2:

Input: 60 -861962556 -627438080 -708319159 -764467622 74640582 350706045 -999789001 -544063777 282451367 27637282 -518718278 -268470867 -45981301 457310521 78126199 -137632720 628617303 -130386090 -356687730 416041029 206813365 -298191714 339206854 967313675 -791204060 317417880 648183698 437133962 -369584705 134286506 -198450450 -187963581 206061261 -986090997 -184050250 -536489678 -255759073 639071712 6184877 205974020 -475579545 -763249876 861785119 -112594346 -734401959 -345250697 -135009327 -630553971 886874616 138561973 121875218 180939754 -77279945 968952108 -809000736 -575180129 -959314537 323585928 -762561133 684987645
Output: -861962556 -861962556 -708319159 -764467622 -708319159 -708319159 -708319159 -708319159 -627438080 -627438080 -544063777 -544063777 -518718278 -518718278 -268470867 -268470867 -137632720 -137632720 -137632720 -137632720 -130386090 -137632720 -130386090 -130386090 -130386090 -130386090 -45981301 -45981301 -45981301 -45981301 -45981301 -130386090 -45981301 -130386090 -130386090 -137632720 -137632720 -137632720 -130386090 -130386090 -130386090 -137632720 -130386090 -130386090 -130386090 -137632720 -135009327 -137632720 -135009327 -135009327 -130386090 -130386090 -112594346 -112594346 -112594346 -130386090 -130386090 -130386090 -130386090 -130386090

Example 3:

Input: 1090 709915472 164876200 -839533201 278354915 233514375 -245220854 -370308796 824885625 -360189011 365793922 -63883831 -17371884 516105436 -613077787 -450372983 -423534088 -126792375 724465698 93264231 -233452276 573902502 -366201774 -910977510 823171753 684019586 -539022306 -854523352 -159275619 -593779112 -175380044 -645726032 909053793 977879038 -579366337 944468345 -395943115 -756022083 936504450 688579596 -490712797 426276021 626131550 947928724 -292491003 -917057717 133782190 844091704 -36624184 144180508 -835401622 214628109 -828427256 785523633 186167595 -331328489 875145363 190193323 -631198164 506221264 -399145812 648675294 -518192972 -413411665 867012548 641460497 -791119683 773442740 -254583682 -242142532 973224939 91538582 474500900 890985070 231661906 -215432021 584064687 -72…
Output: 709915472 164876200 164876200 164876200 233514375 164876200 164876200 164876200 164876200 164876200 164876200 -17371884 164876200 -17371884 -17371884 -63883831 -63883831 -63883831 -17371884 -63883831 -17371884 -63883831 -63883831 -63883831 -17371884 -63883831 -63883831 -126792375 -126792375 -159275619 -159275619 -159275619 -126792375 -159275619 -126792375 -159275619 -159275619 -159275619 -126792375 -159275619 -126792375 -126792375 -63883831 -126792375 -126792375 -126792375 -63883831 -63883831 -36624184 -63883831 -36624184 -63883831 -36624184 -36624184 -36624184 -36624184 -17371884 -36624184 -17371884 -36624184 -17371884 -36624184 -36624184 -36624184 -17371884 -36624184 -17371884 -36624184 -36624184 -36624184 -17371884 -17371884 91538582 91538582 91538582 91538582 91538582 91538582 93264231…

Constraints:

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

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