CT63616

Dev's Wistful marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the steppe camp of Horselord Plains pays by the answer, and Dev intends to earn it. First: the full register of marks. 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: 3399 -696580534 -81385412 -840803310 -966772300 27037074 -297347799 -83495169 88019957 10099866 -493710186 -805128626 -691079141 -37180682 -943627047 270175120 778030017 464152796 -361768484 160800423 -335965251 558378391 411977489 -544630607 -636866284 -614814100 -692055063 -205978215 -982082022 -280592683 -789671698 106326216 344454668 -540460691 -467963838 218895361 856304160 -671133843 -290674628 8535851 985857313 -930339800 -855507395 -368347996 -633569791 528624953 -718465412 12255191 193926420 -157260733 -911491767 -480924496 264731843 533063512 -631945796 -614198240 479869197 124018123 -90546769 78391227 -648143074 -318625124 -168117966 576738654 32794480 -248121234 386979187 955085879 -509918402 627123182 -983802243 490262123 565309113 -894439102 518124090 759624083 -420284072 250…
Output: -696580534 -696580534 -696580534 -840803310 -696580534 -696580534 -297347799 -297347799 -83495169 -297347799 -297347799 -493710186 -297347799 -493710186 -297347799 -297347799 -83495169 -297347799 -83495169 -297347799 -83495169 -83495169 -83495169 -297347799 -297347799 -335965251 -297347799 -335965251 -297347799 -335965251 -297347799 -297347799 -297347799 -335965251 -297347799 -297347799 -297347799 -297347799 -290674628 -290674628 -290674628 -297347799 -297347799 -335965251 -297347799 -335965251 -297347799 -297347799 -290674628 -297347799 -297347799 -297347799 -290674628 -297347799 -297347799 -297347799 -290674628 -290674628 -280592683 -290674628 -290674628 -290674628 -280592683 -280592683 -248121234 -248121234 -205978215 -248121234 -205978215 -248121234 -205978215 -205978215 -205978215 -20…

Example 2:

Input: 3618 445635483 -803951779 -561152637 -764678404 -828554966 513221160 -788431433 -541782798 -243437700 -481370472 -525490935 -255844393 -826109873 232597286 -731890548 165150118 -20242434 -701418263 596453712 899090685 521244721 519833344 699899735 -333158878 175699398 373260400 -561283218 887339286 423222204 871395551 -808506528 -396066615 -364120009 -471315163 -488133174 483977491 288381810 -847842663 -267256989 164697566 750706397 83955275 888891119 356689483 -530187848 -664649109 377196922 528151083 372407040 742107240 859059392 595951515 -374992361 -418744539 -335304068 535713608 -16033354 233918880 -347884566 486215552 -661095412 661213279 156454061 -627148795 845025654 -605568428 478236424 -665541260 -10740092 512454679 -607251217 250022510 472342193 166511561 109940759 -911679740 -5…
Output: 445635483 -803951779 -561152637 -764678404 -764678404 -764678404 -764678404 -764678404 -561152637 -561152637 -541782798 -541782798 -541782798 -541782798 -541782798 -541782798 -525490935 -541782798 -525490935 -525490935 -481370472 -481370472 -255844393 -333158878 -255844393 -255844393 -255844393 -255844393 -243437700 -243437700 -243437700 -255844393 -255844393 -333158878 -333158878 -333158878 -255844393 -333158878 -267256989 -267256989 -255844393 -255844393 -243437700 -243437700 -243437700 -255844393 -243437700 -243437700 -20242434 -20242434 83955275 83955275 83955275 -20242434 -20242434 -20242434 -16033354 -16033354 -16033354 -16033354 -16033354 -16033354 83955275 -16033354 83955275 -16033354 83955275 -16033354 -10740092 -10740092 -10740092 -10740092 83955275 83955275 109940759 83955275 83…

Example 3:

Input: 2056 575398834 243798008 811462267 8238648 -401036656 -985609960 336609281 832881945 -697583330 -800850404 -479387018 859255448 -555345524 782833472 894136889 496334357 -469231910 -527652838 -714464322 138268959 194864625 -836521870 -422554171 -172420847 -138245311 165092227 -479643661 430886292 456112915 201443890 -79176085 -260941266 -738191362 532611265 -420626859 -369178779 487600032 -943412320 926346833 465051198 -470091847 505023902 696240656 966912711 87105541 125856162 878324229 -791736272 -895852397 -10148803 761837185 -620015508 931180005 151767965 780796147 -24057068 220141116 902460726 821726387 722784156 193958659 279657516 -743964670 449294785 -332212262 -901135780 -737583004 -718029887 -386312405 153643721 210076432 763283095 -36782011 991883136 -411330916 606298897 26878547…
Output: 575398834 243798008 575398834 243798008 243798008 8238648 243798008 243798008 243798008 8238648 8238648 8238648 8238648 8238648 243798008 243798008 243798008 8238648 8238648 8238648 138268959 8238648 8238648 -172420847 -138245311 -138245311 -138245311 -138245311 8238648 8238648 8238648 -79176085 -79176085 -79176085 -79176085 -138245311 -79176085 -138245311 -79176085 -79176085 -79176085 -79176085 8238648 8238648 87105541 87105541 125856162 87105541 87105541 8238648 87105541 8238648 87105541 87105541 125856162 87105541 125856162 125856162 138268959 138268959 151767965 151767965 151767965 151767965 151767965 138268959 138268959 125856162 125856162 125856162 138268959 138268959 138268959 138268959 138268959 138268959 151767965 151767965 151767965 138268959 151767965 151767965 153643721 1517679…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Dev's Wistful marks - MEDIUM Coding Problem | CodeTikki