CT63413

Sable's Ledger of ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the coastal hub of Tidewater opens only for a perfect tally of ledgers. Sable means to find out. 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: 588 970980216 374978886 -231175442 -270928844 -370093324 -742268338 -545529463 -530423603 947299269 -510390713 391768270 558172550 -501643161 787111943 928250475 828555583 904429175 735114858 232573791 353872706 423222398 -598947263 -742121050 929003690 100802566 857362501 -317272924 268184213 -851436545 825967295 267643488 -536158161 -469190486 31641587 474904790 725248214 219747686 -703601432 883716995 -598247814 337973837 -460295317 -137563933 697360162 -34703589 723998076 334305071 989489452 657927988 -915355521 61176919 -500657590 -590221561 -103884340 585204366 -755297981 -66655146 -456230229 -391964360 570220014 -196240966 -941915254 -900500724 297874566 406452136 -776194268 -626336902 -677915112 -200574424 -950573997 -48316567 123754956 -411493296 -965808526 -519966265 266764545 -3…
Output: 970980216 374978886 374978886 -231175442 -231175442 -270928844 -270928844 -370093324 -270928844 -370093324 -270928844 -270928844 -270928844 -270928844 -231175442 -231175442 374978886 374978886 374978886 353872706 374978886 353872706 353872706 353872706 353872706 353872706 353872706 268184213 268184213 268184213 268184213 267643488 267643488 232573791 267643488 267643488 267643488 232573791 267643488 232573791 267643488 232573791 232573791 232573791 232573791 232573791 267643488 267643488 268184213 267643488 267643488 232573791 232573791 219747686 232573791 219747686 219747686 100802566 100802566 100802566 100802566 61176919 61176919 61176919 100802566 61176919 61176919 31641587 31641587 -34703589 -34703589 -34703589 -34703589 -48316567 -48316567 -48316567 -48316567 -48316567 -34703589 -347…

Example 2:

Input: 511 331516212 -416719708 805273282 -308219757 344411960 516381640 189799981 152386363 440009352 502400798 -480593975 -332641782 647854790 -749518060 -356419445 105058141 -398924422 -372834865 288172181 448504380 -444296216 -687169966 834700062 -485519011 794454206 -11783479 -410661507 -614707863 -962287211 597177326 716783255 822189421 239083270 -259013376 -752547487 -974077723 969159155 -209523037 -520525699 408668541 308043459 -607918042 -800016312 15965050 338201348 -603264602 644436504 -308473805 921769729 -758185279 322438564 798388695 950044886 234909281 387525770 728644541 -927091645 -606025414 338170925 809354403 -185548346 -642160176 359387940 -800508663 -237503960 571962503 566233782 -364852054 890840069 612779454 -905650625 -531029495 69953310 431759033 -578080816 -773323792 940…
Output: 331516212 -416719708 331516212 -308219757 331516212 331516212 331516212 189799981 331516212 331516212 331516212 189799981 331516212 189799981 189799981 152386363 152386363 105058141 152386363 152386363 152386363 105058141 152386363 105058141 152386363 105058141 105058141 -11783479 -11783479 -11783479 105058141 105058141 152386363 105058141 105058141 -11783479 105058141 -11783479 -11783479 -11783479 105058141 -11783479 -11783479 -11783479 15965050 -11783479 15965050 -11783479 15965050 -11783479 15965050 15965050 105058141 105058141 152386363 152386363 152386363 105058141 152386363 152386363 152386363 105058141 152386363 105058141 105058141 105058141 152386363 105058141 152386363 152386363 152386363 105058141 105058141 105058141 105058141 69953310 105058141 69953310 69953310 15965050 1596505…

Example 3:

Input: 3050 -990459115 64971256 578150459 995379554 747066761 823003153 374344034 463114817 507185696 -880677296 938853843 -468557897 -423684836 -397545441 155143769 -866786942 123703884 -663070727 836311351 7518091 -170636757 880013045 -722052090 -55901413 724710758 -6006946 230698494 -345103910 -934176526 -293955704 -201240621 345602849 -543724520 -327640378 601339091 -347818253 107115675 -834345930 258809802 -187362976 438450535 759956668 789591171 418413150 918548173 -979245923 -69880400 -529645550 160558867 -549451143 -964325977 559419509 -351360360 -38837451 -987366988 -416790383 -386753515 -37595187 973583669 575926020 -808709840 -667246426 484299164 539536106 -992044775 57983135 -13992001 416879677 348830962 -283874255 308534819 804260634 -31071204 -61324232 730044507 -841433808 -78942975…
Output: -990459115 -990459115 64971256 64971256 578150459 578150459 578150459 463114817 507185696 463114817 507185696 463114817 463114817 374344034 374344034 155143769 155143769 123703884 155143769 123703884 123703884 123703884 123703884 64971256 123703884 64971256 123703884 64971256 64971256 7518091 7518091 7518091 7518091 -6006946 7518091 -6006946 7518091 -6006946 7518091 -6006946 7518091 7518091 64971256 64971256 107115675 64971256 64971256 7518091 64971256 7518091 7518091 7518091 7518091 -6006946 -6006946 -38837451 -38837451 -38837451 -37595187 -37595187 -37595187 -38837451 -37595187 -37595187 -37595187 -37595187 -13992001 -13992001 -6006946 -13992001 -6006946 -6006946 -6006946 -13992001 -6006946 -13992001 -13992001 -13992001 -13992001 -31071204 -31071204 -31071204 -13992001 -31071204 -1399200…

Constraints:

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

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