CT57726

The Winterholt Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the snowberry thicket of Winterholt pays by the answer, and Milo intends to earn it. First: the full register of ledgers. 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: 2917 306141319 -920452417 -58144772 -221936106 557833752 -34151007 -568205726 832820930 233778650 -982794256 -810743846 -415931730 311056832 -888460563 -369441852 276003101 718322779 -538987621 456897489 289218762 272543177 656245838 561563526 976364848 -893779267 -226969069 684655828 -910158314 -978455876 789423042 -721590671 108373121 406320381 -869217959 -126604697 -682113507 197246847 94315521 -474969014 98178004 -121843596 -850086001 -15530516 -691508900 245575897 606852352 667438561 -208199536 -796289746 49779994 787438396 120354660 274251350 248016594 811808425 557869031 -791338494 -573595574 853068052 235101168 805787877 -593305693 195984571 -337076542 -82341521 36494169 580340156 -673721225 -475486788 841052146 -703294195 789556447 -4715085 -68073320 210878214 922664917 -308265818…
Output: 306141319 -920452417 -58144772 -221936106 -58144772 -58144772 -58144772 -58144772 -34151007 -58144772 -58144772 -221936106 -58144772 -221936106 -221936106 -221936106 -58144772 -221936106 -58144772 -58144772 -34151007 -34151007 233778650 233778650 233778650 -34151007 233778650 -34151007 -34151007 -34151007 -34151007 -34151007 108373121 -34151007 -34151007 -58144772 -34151007 -34151007 -34151007 -34151007 -34151007 -58144772 -34151007 -58144772 -34151007 -34151007 -15530516 -34151007 -34151007 -34151007 -15530516 -15530516 49779994 49779994 94315521 94315521 94315521 49779994 94315521 94315521 98178004 94315521 98178004 94315521 94315521 49779994 94315521 49779994 49779994 49779994 49779994 49779994 49779994 36494169 49779994 49779994 49779994 36494169 36494169 -4715085 36494169 -4715085 -47…

Example 2:

Input: 762 971332904 -84323405 337797460 -305944328 -618870799 -287587948 -537156107 404498953 568327616 -910375882 732750408 405990403 -9582363 -741020003 -770870627 -18227689 418691800 709844316 -600723862 -733218116 -942336781 -785120788 -321251910 36241939 -129145831 795728003 -141536608 -979603310 -700660685 -140149628 227416283 494139122 -867395859 160871335 968056298 476325165 -3825496 225538444 -460876615 890008868 -307041137 793846907 693155198 621467134 -747032929 -546251277 353550015 -769197381 403413657 -492059454 105513748 -264483253 320228186 -548223206 736586517 -345121525 758359135 -743606042 155694758 440392181 1511703 78115678 639188879 -832366369 -565880820 -318911834 327516928 -777825537 -957774803 -62563004 -80140823 -129838194 -378670582 672563163 820035698 -510445244 -91232…
Output: 971332904 -84323405 337797460 -84323405 -84323405 -287587948 -287587948 -287587948 -84323405 -287587948 -84323405 -84323405 -9582363 -84323405 -84323405 -84323405 -18227689 -18227689 -18227689 -84323405 -84323405 -287587948 -287587948 -287587948 -129145831 -129145831 -129145831 -141536608 -141536608 -141536608 -140149628 -140149628 -140149628 -140149628 -129145831 -129145831 -84323405 -84323405 -84323405 -84323405 -84323405 -84323405 -18227689 -18227689 -18227689 -84323405 -18227689 -84323405 -18227689 -84323405 -18227689 -84323405 -18227689 -84323405 -18227689 -84323405 -18227689 -84323405 -18227689 -18227689 -9582363 -9582363 -3825496 -9582363 -9582363 -18227689 -9582363 -18227689 -18227689 -62563004 -62563004 -80140823 -80140823 -80140823 -62563004 -80140823 -80140823 -80140823 -6256300…

Example 3:

Input: 1252 -985543206 -726372803 -101538598 -253627429 -815257141 -452185078 247147909 630570457 354349705 28623610 -520284250 -525747575 -952295987 678821266 -288588952 410959688 940952592 -811467981 188605746 885056376 -770242922 399199324 838501623 -41798098 482848771 194674531 -286786129 722947484 -549597735 -536541329 967684179 176054201 -221763527 -977270839 -43496602 -762191254 185748151 36010279 127672002 315155400 373981419 376489839 -142783509 46052107 -875144713 -494975813 897299584 186480504 221012519 -34042515 -288005407 769527172 558284907 -916961700 252575684 -666945904 -514126925 -921367103 -591444850 451120356 905838680 121535029 528214356 -734900323 403872550 680999173 244141933 319069521 -128622740 -193455044 -58364241 -564672106 -105001621 60391126 -781822576 -212572131 -6354…
Output: -985543206 -985543206 -726372803 -726372803 -726372803 -726372803 -452185078 -452185078 -253627429 -253627429 -253627429 -452185078 -452185078 -452185078 -288588952 -288588952 -253627429 -288588952 -253627429 -253627429 -253627429 -253627429 -101538598 -101538598 -41798098 -41798098 -41798098 -41798098 -41798098 -101538598 -41798098 -41798098 -41798098 -101538598 -43496602 -101538598 -43496602 -43496602 -41798098 -41798098 28623610 28623610 28623610 28623610 28623610 -41798098 28623610 28623610 36010279 28623610 28623610 28623610 36010279 28623610 36010279 28623610 28623610 -34042515 -34042515 -34042515 28623610 28623610 36010279 28623610 36010279 36010279 46052107 46052107 46052107 36010279 36010279 28623610 28623610 28623610 28623610 -34042515 -34042515 -34042515 28623610 -15107348 -1510…

Constraints:

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

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