CT61378

Navigator's signals Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the lantern reef of Glowtide, Navigator the registry keeper keeps careful count of the signals. settle the inheritance fairly, every figure matters. 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: 1701 808915383 -579822280 419749093 804711200 472088302 -28567513 -7241306 328681330 287617335 966144809 -122720310 76894941 -92026678 -338595521 436639353 568608031 -720882611 306474319 -250635477 -841351576 202979169 -682261943 765660853 246917108 -789601705 486815619 353061405 924920057 -899820258 58590822 -756802256 -886147682 -39867981 -950962872 879911678 186054162 -465303712 -343572645 -938877178 562272197 378211130 776498704 248621918 -139122649 -436918658 374764012 640320110 -60424703 -295195938 -658539355 314224425 -660479871 25247714 -179290429 652163426 -199508852 427452221 -219868369 -4829868 -95235912 -717528865 -781811176 900986546 461571241 147863689 -380472276 238744625 511429426 485468283 -925930245 95167651 -265077432 -806678379 -16681119 -604014919 152039722 -231607001 …
Output: 808915383 -579822280 419749093 419749093 472088302 419749093 419749093 328681330 328681330 328681330 328681330 287617335 287617335 76894941 287617335 287617335 287617335 287617335 287617335 76894941 202979169 76894941 202979169 202979169 202979169 202979169 246917108 246917108 246917108 202979169 202979169 76894941 76894941 58590822 76894941 76894941 76894941 58590822 58590822 58590822 76894941 76894941 186054162 76894941 76894941 76894941 186054162 76894941 76894941 58590822 76894941 58590822 58590822 25247714 58590822 25247714 58590822 25247714 25247714 -4829868 -4829868 -7241306 -4829868 -4829868 25247714 -4829868 25247714 25247714 58590822 25247714 58590822 25247714 25247714 -4829868 -4829868 -4829868 -4829868 -7241306 -4829868 -4829868 -4829868 -7241306 -7241306 -16681119 -16681119 -2…

Example 2:

Input: 3199 445816298 215213658 426990956 818900741 -114814478 -760197113 -781670627 -451011636 826439798 -559163644 975750443 209490936 -498021505 320666877 392249080 -740126924 873335625 -654063669 -623204391 566463474 436460639 402425403 -502740678 -25202549 -19284451 633169528 -886702673 16087930 884892030 -805877520 -598800770 391956797 -338345633 206951656 290147286 12085215 162291236 913970486 -618378125 -791206547 386038794 322328956 -935433187 -638114318 680533449 542468764 -365635590 362025998 -152037794 209540384 -80350381 459242940 -653786525 417540307 41685364 659816457 787341188 979829099 175825278 747209341 407129807 897466669 653387815 -220171859 -296208279 878673439 473423747 -314333611 -409017707 265569459 844453221 101684233 -750929765 259714911 474863106 364891769 -907689208 -…
Output: 445816298 215213658 426990956 426990956 426990956 215213658 215213658 -114814478 215213658 -114814478 215213658 209490936 209490936 209490936 215213658 209490936 215213658 209490936 209490936 209490936 215213658 215213658 215213658 209490936 209490936 209490936 209490936 16087930 209490936 16087930 16087930 16087930 16087930 16087930 206951656 16087930 162291236 162291236 162291236 16087930 162291236 162291236 162291236 16087930 162291236 162291236 162291236 162291236 162291236 162291236 162291236 162291236 162291236 162291236 162291236 162291236 206951656 206951656 206951656 206951656 209490936 209490936 209540384 209490936 209490936 209490936 209540384 209490936 209490936 209490936 209540384 209490936 209490936 209490936 209540384 209540384 209540384 209490936 209540384 209490936 2095403…

Example 3:

Input: 2225 -879749779 704076365 -237049235 -43620293 277616892 299859103 -52143568 72640331 246558912 985887752 -414684397 -91622374 -686616156 15693593 -134579666 -665280396 146606547 -901827475 473010616 121346358 -168576476 225078074 607736519 -854248416 314921828 -642608772 856197199 -273705806 -369258053 990738134 -138638260 -930536188 882554701 -527826468 -589744990 894135172 -873575874 -424018393 -742409540 -703931549 807666120 134841678 -472057863 52281008 -697362231 506842254 -159585812 23503000 146943363 444857481 -626090526 -458755437 -86964898 703283958 313863158 -964823858 -254866946 287381397 673951245 446107874 168579891 -972245297 -360493836 -632820052 408221075 -619465034 -127645565 758744084 58749387 173229517 -796953815 928818573 -608951304 -402195111 91860105 804452785 -72883…
Output: -879749779 -879749779 -237049235 -237049235 -43620293 -43620293 -43620293 -43620293 72640331 72640331 72640331 -43620293 -43620293 -43620293 -43620293 -52143568 -43620293 -52143568 -43620293 -43620293 -43620293 -43620293 15693593 -43620293 15693593 -43620293 15693593 -43620293 -43620293 -43620293 -43620293 -52143568 -43620293 -52143568 -52143568 -52143568 -52143568 -91622374 -91622374 -134579666 -91622374 -91622374 -91622374 -91622374 -91622374 -91622374 -91622374 -91622374 -52143568 -52143568 -52143568 -91622374 -86964898 -86964898 -52143568 -86964898 -86964898 -86964898 -52143568 -52143568 -43620293 -52143568 -52143568 -86964898 -52143568 -86964898 -86964898 -86964898 -52143568 -52143568 -52143568 -52143568 -52143568 -86964898 -52143568 -52143568 -52143568 -86964898 -52143568 -86964898 -…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Navigator's signals Middle So Far - MEDIUM Coding Problem | CodeTikki