CT60276

Envoy's Middle So Far Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the railway depot of Cinderline as Envoy unrolls the day's manifest of beacons. The tally will decide the next shipment. 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: 2815 -720040323 -987700275 81491494 339129866 -777769951 312122857 -110385114 -254322084 765951512 -580367152 701059688 -808532216 964372421 -664231867 -645743256 838597445 293906137 574586167 23830221 -876122977 -901179556 -643129118 -328634674 426343504 150068460 536313909 -791719899 413829138 363364437 -92080999 -507967278 664734301 -340724426 974279382 -862518945 918438743 -69202804 424067235 -846115600 958157897 895928649 -867091113 -509590245 -324809601 868693777 303508713 -475640596 -600271742 53944962 951101404 -601792 -362080663 -393879014 -992407309 588903104 981606513 -548419714 -219984947 57088329 711151517 998818135 -787664897 -689133131 828256966 -219114475 289704650 545707060 83245933 -884598317 521616791 884403940 826691082 -802905015 508730984 -378738904 -962104286 1857168…
Output: -720040323 -987700275 -720040323 -720040323 -720040323 -720040323 -110385114 -254322084 -110385114 -254322084 -110385114 -254322084 -110385114 -254322084 -254322084 -254322084 -110385114 -110385114 23830221 -110385114 -110385114 -254322084 -254322084 -254322084 -110385114 -110385114 -110385114 -110385114 23830221 -92080999 -92080999 -92080999 -92080999 -92080999 -92080999 -92080999 -69202804 -69202804 -69202804 -69202804 23830221 -69202804 -69202804 -92080999 -69202804 -69202804 -69202804 -92080999 -69202804 -69202804 -601792 -69202804 -69202804 -92080999 -69202804 -69202804 -69202804 -92080999 -69202804 -69202804 -601792 -69202804 -69202804 -69202804 -69202804 -69202804 -601792 -601792 -601792 -601792 23830221 23830221 23830221 23830221 23830221 -601792 23830221 23830221 23830221 23830221…

Example 2:

Input: 2836 950528079 823630103 392065384 934207706 712933287 -2402402 557213691 -744262544 -878039091 -710310473 -55419570 773178026 -90646180 836526250 -436347553 538967082 750051267 -649331547 517180517 -362756493 777896379 -354931858 370699965 -562812920 -728010611 -337677229 -953786946 -428420081 291579183 -491428975 431880548 -980913680 516777124 521614274 623607776 316240652 -817388251 11782786 -323263998 813399834 35845370 -724674851 406158457 618952111 -958519934 -20603973 -37169000 69162417 -920069856 464885822 709038210 -151026690 171435339 -537874079 807487614 688542964 459016833 -923432177 251302865 -731373291 376435179 692985299 667428217 937220783 413441420 -106400998 96194673 475671053 -516308560 -817865523 -92299265 -747795844 803925989 -643355848 91102473 -693906319 547254070 -6…
Output: 950528079 823630103 823630103 823630103 823630103 712933287 712933287 557213691 557213691 392065384 392065384 392065384 392065384 392065384 392065384 392065384 538967082 392065384 517180517 392065384 517180517 392065384 392065384 370699965 370699965 -2402402 -2402402 -55419570 -2402402 -55419570 -2402402 -55419570 -2402402 -2402402 291579183 291579183 291579183 11782786 11782786 11782786 35845370 11782786 35845370 35845370 35845370 11782786 11782786 11782786 11782786 11782786 35845370 11782786 35845370 11782786 35845370 35845370 69162417 35845370 69162417 35845370 69162417 69162417 171435339 171435339 251302865 171435339 171435339 171435339 171435339 96194673 96194673 69162417 96194673 69162417 91102473 69162417 91102473 69162417 69162417 35845370 35845370 35845370 35845370 11782786 358453…

Example 3:

Input: 1086 953891333 469457968 172360343 -97710693 410560246 573321722 -180827982 -791965946 545739247 9901521 421424252 491514949 238304717 -691464573 -978918765 354253646 -713286818 -884411689 -645760987 517399688 105262082 -982814214 -333779796 179148845 -11714842 698383893 -522984779 -9260727 945695708 -594907864 899511073 -464023973 -24058910 273340688 765410500 740642427 -573686209 -169651040 -853017588 601949998 263274442 520993087 -185308965 538034977 107646189 -721876593 -978545020 -787058425 -800836674 541944691 -106084957 -398530036 84644079 715085787 71355263 759473638 -968179918 -743247478 -851239171 225667861 420552056 -265425064 -985091284 647402388 694497907 -85706080 -242782839 -798462258 779191307 814992198 -567167995 10824449 -323966248 -913856006 -559031305 991360460 73425568…
Output: 953891333 469457968 469457968 172360343 410560246 410560246 410560246 172360343 410560246 172360343 410560246 410560246 410560246 238304717 238304717 238304717 238304717 172360343 172360343 172360343 172360343 105262082 105262082 105262082 105262082 105262082 105262082 9901521 105262082 9901521 105262082 9901521 9901521 9901521 105262082 105262082 105262082 9901521 9901521 9901521 105262082 105262082 105262082 105262082 107646189 105262082 105262082 9901521 9901521 9901521 9901521 -9260727 9901521 9901521 71355263 71355263 71355263 9901521 9901521 9901521 71355263 9901521 9901521 9901521 71355263 9901521 9901521 -9260727 9901521 9901521 9901521 9901521 9901521 -9260727 -9260727 -9260727 9901521 -9260727 9901521 -9260727 9901521 -9260727 9901521 -9260727 -9260727 -9260727 -9260727 -9260727 …

Constraints:

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

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