CT63255

Yash's Misty signals

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the ink district of Scriptoria with crates of signals, and Yash the auditor must account for every last one. 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: 1119 675175235 145639457 492757923 -62618798 -289719830 -433643593 798337220 647345308 401702536 -36619004 -250546381 239996300 -645121086 -339589024 -991334650 325210865 719572008 -329356735 906332146 -962102666 452850277 442269809 418660201 -816804706 -191032764 502404630 864527392 958884307 330455556 -838865859 -96059341 563034122 -48668659 -754695408 -918065373 6187975 283158135 -986029158 -293166067 -887809351 822126477 175001038 -723232791 -866200009 235257783 957493940 -386432983 148961067 344142400 924180944 631653474 -618970829 -590016507 -24144381 195848724 541741308 625672705 -28855584 -576242543 -536247196 815609276 -277043215 617767309 -875244112 -678177834 -880527031 881523190 328720662 169632607 -919109788 713492353 242041101 -433562282 499671399 -692840702 -557013774 -53800…
Output: 675175235 145639457 492757923 145639457 145639457 -62618798 145639457 145639457 401702536 145639457 145639457 145639457 145639457 -36619004 -36619004 -36619004 145639457 -36619004 145639457 -36619004 145639457 145639457 239996300 145639457 145639457 145639457 239996300 239996300 325210865 239996300 239996300 239996300 239996300 145639457 145639457 6187975 145639457 6187975 6187975 -36619004 6187975 6187975 6187975 -36619004 6187975 6187975 6187975 6187975 145639457 145639457 148961067 145639457 145639457 6187975 145639457 145639457 148961067 145639457 145639457 6187975 145639457 6187975 145639457 6187975 6187975 -24144381 6187975 6187975 145639457 6187975 145639457 145639457 145639457 145639457 145639457 6187975 6187975 6187975 145639457 6187975 6519436 6187975 6187975 6187975 6187975 -241…

Example 2:

Input: 1533 -174737736 -276074019 346796324 307418158 900204647 -475638905 -964266579 -341662714 630892309 964293331 739805514 514038374 819368612 768172419 493592919 404295903 835148010 894385817 613729986 -200292010 887484516 739277748 795965872 446536922 355833823 -882362050 -793518395 -612482990 68628269 336015741 112120383 929717598 -721370849 554463937 -429374686 -850767370 720706278 -401035211 455677814 -909647711 -227038809 -602193405 -861435222 -909127251 788484418 78344144 514901205 -310691733 -332003152 513060811 137376674 -743939704 -841458779 -720784282 191727612 -58249129 95876617 -782559880 443385227 -991414452 805231418 -166197754 103615995 -191789074 -101586648 -910909797 -873822012 424248657 -610706641 605082119 309688170 286066305 -543478754 -784171289 974062523 956997340 -9775…
Output: -174737736 -276074019 -174737736 -174737736 307418158 -174737736 -174737736 -276074019 -174737736 -174737736 307418158 307418158 346796324 346796324 493592919 404295903 493592919 493592919 514038374 493592919 514038374 514038374 613729986 514038374 514038374 493592919 493592919 446536922 446536922 404295903 404295903 404295903 404295903 404295903 404295903 355833823 404295903 355833823 404295903 355833823 355833823 346796324 346796324 336015741 346796324 336015741 346796324 336015741 336015741 336015741 336015741 307418158 307418158 137376674 191727612 137376674 137376674 112120383 137376674 112120383 137376674 112120383 112120383 103615995 103615995 95876617 95876617 95876617 95876617 95876617 103615995 103615995 103615995 95876617 103615995 103615995 103615995 95876617 95876617 78344144 …

Example 3:

Input: 3352 -936952547 273006221 -1844666 -938662304 -719787552 -490998576 920883639 618108913 304026016 454063856 43125697 480642468 -312005436 -788926497 -622121362 -575206700 660926568 807155109 79109391 -828373567 684325421 93343905 863807745 -359436285 -560320181 308352014 -521157263 -802214713 -423964937 258942412 450583028 -390462678 793114549 -773323323 110775867 662742940 247109954 -713733584 617093287 443343822 -23855055 -353473307 158358259 700556374 -255259365 -374550465 -278552711 -986706843 950983042 130053725 -888357912 -421825875 799386080 -257873699 -533331223 -529489244 -671196919 992424925 -362533269 183770209 726342419 383792298 -728440602 122574105 -546310751 943611525 379587556 861054406 -518055081 195044724 768145453 196450389 577398291 165012543 184649777 368050738 -668531…
Output: -936952547 -936952547 -1844666 -936952547 -719787552 -719787552 -490998576 -490998576 -1844666 -1844666 43125697 43125697 43125697 -1844666 -1844666 -312005436 -1844666 -1844666 43125697 -1844666 43125697 43125697 79109391 43125697 43125697 43125697 43125697 -1844666 -1844666 -1844666 43125697 -1844666 43125697 -1844666 43125697 43125697 79109391 43125697 79109391 79109391 79109391 43125697 79109391 79109391 79109391 43125697 43125697 -1844666 43125697 43125697 43125697 -1844666 43125697 -1844666 -1844666 -23855055 -23855055 -23855055 -23855055 -23855055 -1844666 -1844666 -1844666 -1844666 -1844666 -1844666 43125697 43125697 43125697 43125697 79109391 79109391 93343905 93343905 110775867 110775867 110775867 93343905 110775867 93343905 93343905 79109391 93343905 93343905 110775867 110775867…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Yash's Misty signals - MEDIUM Coding Problem | CodeTikki