CT59001

The Northern signals of Axel

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Axel runs the bakery at the willow walks of Reedmarsh. Today the books show a list of signals, 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: 3846 -902414402 -364597990 -556924449 64337411 -805618056 -323508545 409798932 -149683489 -383701280 -682872394 165048844 425650195 -517464329 18234233 415521910 -704593995 -102641293 -13571931 139529684 966675085 -1740151 611488998 -817568178 757029005 -601121201 -692013175 794574565 659410118 -926980942 -115291919 -844388940 -612297170 -293099159 -829029575 503187268 836955587 -934589196 866189124 761867116 857878499 -872129143 204059360 -102909665 -114911518 129996576 -692406011 -829481776 -462117070 -823543847 -744179309 548790884 -120420821 -362561163 -468390429 -256462985 550042720 -146880930 982344734 870378738 -806750078 -575173928 -512228110 97174342 942087445 -363562160 414488931 -954662864 -316725662 -766546656 -970397126 540835208 -280697404 195953707 106800828 -525474633 45010…
Output: -902414402 -902414402 -556924449 -556924449 -556924449 -556924449 -364597990 -364597990 -364597990 -383701280 -364597990 -364597990 -364597990 -364597990 -323508545 -364597990 -323508545 -323508545 -149683489 -149683489 -102641293 -102641293 -102641293 -102641293 -102641293 -149683489 -102641293 -102641293 -102641293 -115291919 -115291919 -149683489 -149683489 -293099159 -149683489 -149683489 -149683489 -149683489 -115291919 -115291919 -115291919 -115291919 -102909665 -114911518 -102909665 -114911518 -114911518 -115291919 -115291919 -149683489 -115291919 -120420821 -120420821 -149683489 -149683489 -149683489 -146880930 -146880930 -120420821 -146880930 -146880930 -149683489 -146880930 -146880930 -146880930 -146880930 -146880930 -149683489 -149683489 -256462985 -149683489 -256462985 -1496834…

Example 2:

Input: 3878 -579161062 -403162800 484611061 -165750703 195343107 76707889 590623352 -172789707 722873746 -516116195 635059732 -903117115 283513187 724173533 -636139228 -431752932 -773311988 968356175 -518295210 161945520 40686511 939901749 -738701172 -645571704 5075358 -865204347 512905492 150529982 515489146 -968404361 -981322871 -812867635 648317020 -795643941 -295452445 -777682391 -673673599 51786071 -827238102 -257365125 597208313 940942590 40520249 -472707628 830101467 141448686 901286809 -361507238 -520085126 -781615907 43332302 -31022735 -38951262 -754888334 893769888 279733247 -242073406 876535640 -521422154 400950980 601159546 -538522601 -848373115 535939600 926597140 142486315 135595561 -128355728 886141473 714393846 717044974 -466304555 -685579583 -886339213 -366252429 41470059 6714603…
Output: -579161062 -579161062 -403162800 -403162800 -165750703 -165750703 76707889 -165750703 76707889 -165750703 76707889 -165750703 76707889 76707889 76707889 -165750703 -165750703 -165750703 -165750703 -165750703 40686511 40686511 40686511 -165750703 5075358 -165750703 5075358 5075358 40686511 5075358 5075358 -165750703 5075358 -165750703 -165750703 -172789707 -172789707 -172789707 -172789707 -257365125 -172789707 -172789707 -165750703 -172789707 -165750703 -165750703 5075358 -165750703 -165750703 -172789707 -165750703 -165750703 -38951262 -165750703 -38951262 -38951262 -38951262 -38951262 -38951262 -38951262 -31022735 -38951262 -38951262 -38951262 -31022735 -31022735 5075358 -31022735 5075358 5075358 40520249 5075358 5075358 -31022735 -31022735 -31022735 5075358 -31022735 -31022735 -31022735 -…

Example 3:

Input: 929 -809608170 487101774 894599868 620374386 953074081 -395789367 189737797 -416721385 -334433253 -821311046 710211150 -777962374 -862615652 -358258062 13957021 -485342257 492679211 127015752 424690094 772086799 656826074 -992850824 -983719313 868998851 -644233233 578096187 411220844 631655699 337312736 541280244 663705960 -918332107 677417522 -778947286 -551865985 872619390 42890026 -425121934 -965938152 791672047 705577319 876248061 -272268837 520459173 378663646 101387958 38945755 470691504 -22106036 -638033899 723927112 469655456 27025040 362097169 -164502101 7554277 -272655604 402177762 -733613511 -191951812 -9208034 628294348 555604925 -959702022 501235190 -522224037 918147036 358902534 -493885399 169094311 -201959322 -137978354 786522563 983559884 -376246130 893588372 738730330 -409…
Output: -809608170 -809608170 487101774 487101774 620374386 487101774 487101774 189737797 189737797 -334433253 189737797 -334433253 -334433253 -358258062 -334433253 -358258062 -334433253 -334433253 13957021 13957021 127015752 13957021 13957021 13957021 13957021 13957021 127015752 127015752 189737797 189737797 337312736 189737797 337312736 189737797 189737797 189737797 189737797 127015752 127015752 127015752 189737797 189737797 189737797 189737797 337312736 189737797 189737797 189737797 189737797 127015752 189737797 189737797 189737797 189737797 189737797 127015752 127015752 127015752 127015752 101387958 101387958 101387958 127015752 101387958 127015752 101387958 127015752 127015752 127015752 127015752 127015752 101387958 127015752 127015752 127015752 127015752 169094311 127015752 127015752 1270157…

Constraints:

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

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