CT65248

The registers at Cascade Vale

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the ribbon falls of Cascade Vale, Nina records each registers in a worn leather ledger. The guild wants answers, not guesses. 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: 1185 650683326 625226585 566148408 -878279091 425147791 -467512043 -294194996 -321102439 -410853047 -527260856 -318104393 -987906123 -612627692 -679083734 -287048895 301284137 -845138261 -882516399 177581650 234315363 430185259 109732370 100545136 -126155032 723337178 762249946 -420256568 -367479575 505644960 514097866 248672351 437112129 -116347108 46709517 458001222 -405127797 989547553 192247780 -258023221 204829650 757649891 -864146444 -762853213 21337079 -238804044 251535125 310027511 -140840640 434753415 -332974070 -104482016 -392287792 -757466029 -336183267 -478668820 -441204747 350389139 540521113 725756649 -406826549 -837591851 -44204758 641619461 -995991672 -971976465 -746839064 643955770 -463276845 -798076870 14265193 846982830 -698289613 483069496 974556921 -215830641 810831054…
Output: 650683326 625226585 625226585 566148408 566148408 425147791 425147791 -294194996 -294194996 -321102439 -318104393 -321102439 -321102439 -410853047 -321102439 -321102439 -321102439 -410853047 -321102439 -321102439 -318104393 -318104393 -294194996 -294194996 -287048895 -287048895 -287048895 -294194996 -287048895 -287048895 -126155032 -126155032 -116347108 -116347108 46709517 -116347108 46709517 46709517 46709517 46709517 100545136 46709517 46709517 21337079 21337079 21337079 46709517 21337079 46709517 21337079 21337079 -104482016 -104482016 -116347108 -116347108 -126155032 -116347108 -116347108 -104482016 -116347108 -116347108 -116347108 -104482016 -116347108 -116347108 -126155032 -116347108 -126155032 -126155032 -126155032 -116347108 -126155032 -116347108 -116347108 -116347108 -116347108 -1…

Example 2:

Input: 643 -538060654 409772749 -460922697 358650452 -604957200 -777792992 217203270 263725261 695893550 -88348201 -382776263 -161080113 442670691 843878127 -512341600 614996692 395128244 -570568799 977770943 -480324284 -978607358 344426401 -484439744 296190649 -139433621 581518728 213504344 -272537206 424393457 422591991 637748819 141409806 999611986 -306725316 978824335 380718678 -120787686 119898854 -598565119 588457645 871736886 -456423165 553683783 -124299485 402336220 -877770880 571832435 370164750 -538703042 150190182 369467381 871913649 -404063146 -962214538 -416943094 -283275568 -842110064 -381096513 866237865 578772674 -631689938 -469333232 -419096264 206085789 -168820155 431827706 -109917878 764577344 -985213245 870848347 -179418658 -397468920 550028238 621240168 -723568103 410263886 -…
Output: -538060654 -538060654 -460922697 -460922697 -460922697 -538060654 -460922697 -460922697 217203270 -88348201 -88348201 -161080113 -88348201 -88348201 -88348201 -88348201 217203270 -88348201 217203270 -88348201 -88348201 -88348201 -88348201 -88348201 -88348201 -88348201 213504344 -88348201 213504344 213504344 217203270 213504344 217203270 213504344 217203270 217203270 217203270 213504344 213504344 213504344 217203270 213504344 217203270 213504344 217203270 213504344 217203270 217203270 217203270 213504344 217203270 217203270 217203270 213504344 213504344 150190182 150190182 141409806 150190182 150190182 150190182 141409806 141409806 141409806 141409806 141409806 141409806 141409806 141409806 141409806 141409806 119898854 141409806 141409806 141409806 141409806 141409806 141409806 141409806 1…

Example 3:

Input: 3949 -541129832 -829641763 126050003 377826452 633998540 263613437 -269342636 73935538 -420809577 771949091 -393810808 -805808134 864775633 763184486 -544212380 245098637 -12120151 -429317897 -787990521 171424853 -166364301 432469400 420564207 799949642 -734745227 578649579 -267886918 -151112125 52819898 761022412 -631834640 972782825 55114027 734757544 -84222620 -123720741 -638451076 -514348819 73809668 -313622353 416457873 402354341 649173626 421784788 -130775884 -981813487 -955793494 550511002 -127482711 396756490 -989514063 351353239 -91480032 61673368 -724304569 624936301 -249243589 -654664396 -655172018 294988678 -814985695 -7463 10422523 277662700 120316536 -364421171 -294425696 113731764 885416858 68822299 -559189279 363336220 -88207223 300525811 113302708 -845973335 -890619058 119…
Output: -541129832 -829641763 -541129832 -541129832 126050003 126050003 126050003 73935538 73935538 73935538 73935538 -269342636 73935538 73935538 73935538 73935538 73935538 -12120151 -12120151 -12120151 -12120151 -12120151 73935538 73935538 73935538 73935538 73935538 -12120151 52819898 52819898 52819898 52819898 55114027 55114027 55114027 52819898 52819898 -12120151 52819898 -12120151 52819898 52819898 55114027 55114027 55114027 52819898 52819898 52819898 52819898 52819898 52819898 52819898 52819898 52819898 52819898 52819898 52819898 -12120151 -12120151 -12120151 -12120151 -12120151 -7463 -7463 10422523 -7463 -7463 -7463 10422523 10422523 10422523 10422523 10422523 10422523 52819898 10422523 10422523 10422523 52819898 10422523 52819898 52819898 55114027 52819898 55114027 55114027 61673368 551140…

Constraints:

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

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