CT59878

The beacons Middle So Far Puzzle

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the floating docks of Skyharbor, Lila studies rows of beacons entries. One clean number will settle the guild's oldest argument. 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: 3130 408858917 -317226757 694909829 -595364245 -708609633 -176107533 -611800278 916669252 -712942452 -975814952 -926723067 44783421 -36516041 38207355 -245479223 209353545 -469260159 -689737707 446081415 215018185 -510729976 706506522 -481851743 836286369 -378547213 -602629936 -534162640 -152390190 605039359 977594568 -849389158 -10107110 335119135 -762318515 367595700 578179490 -541592219 696557809 -129673797 521105260 -746992887 -697682006 -374780700 -997423340 877152678 -372761911 -599592189 -386126697 411423311 -303988946 -157871739 710553337 29238646 633663032 -927789244 543732537 249753032 -382951729 771808291 268704451 470505693 33196847 -997276806 -192638204 556918820 796989786 83439156 387200293 582268907 -81913222 -709615156 860991402 -787714925 -42728120 89029896 344685390 88509…
Output: 408858917 -317226757 408858917 -317226757 -317226757 -317226757 -317226757 -317226757 -317226757 -595364245 -595364245 -595364245 -317226757 -317226757 -245479223 -245479223 -245479223 -317226757 -245479223 -245479223 -245479223 -245479223 -245479223 -245479223 -245479223 -317226757 -317226757 -317226757 -245479223 -245479223 -245479223 -245479223 -176107533 -245479223 -176107533 -176107533 -176107533 -176107533 -152390190 -152390190 -152390190 -176107533 -176107533 -245479223 -176107533 -245479223 -245479223 -317226757 -245479223 -303988946 -245479223 -245479223 -176107533 -176107533 -176107533 -176107533 -157871739 -176107533 -157871739 -157871739 -152390190 -152390190 -152390190 -157871739 -152390190 -152390190 -129673797 -129673797 -36516041 -81913222 -81913222 -81913222 -81913222 -819…

Example 2:

Input: 462 -968421843 -280862818 423080422 865607685 -80757374 -233159867 142456653 -651169645 -81296691 323690582 -478674672 -416133732 -117641130 884177332 -822880036 745458107 -998896214 151974216 -420650230 -782175223 -896867266 -364363450 -69085042 277052696 110538469 -907750371 -580403199 856696869 160283689 144382690 286358311 606013200 -416901850 -525721741 -739954579 -87611912 925853934 902908697 -480158160 -394185303 554607573 557876643 -29066674 -294497883 809657387 155588700 -942861548 362334160 -499642110 350598233 -491351688 880046585 161999431 478835410 -284137923 -38501500 481074036 -765902313 503166724 -20646247 -810144590 -7043520 432109057 197505584 -129334685 -870420807 -943653771 934651156 -202237241 -528208834 -96405077 -980680557 -616162320 -179633738 162143166 863139194 90…
Output: -968421843 -968421843 -280862818 -280862818 -80757374 -233159867 -80757374 -233159867 -81296691 -81296691 -81296691 -233159867 -117641130 -117641130 -117641130 -117641130 -117641130 -117641130 -117641130 -233159867 -233159867 -280862818 -233159867 -233159867 -117641130 -233159867 -233159867 -233159867 -117641130 -117641130 -81296691 -81296691 -81296691 -117641130 -117641130 -117641130 -87611912 -87611912 -87611912 -117641130 -87611912 -87611912 -81296691 -87611912 -81296691 -81296691 -81296691 -81296691 -81296691 -81296691 -81296691 -81296691 -80757374 -80757374 -80757374 -80757374 -69085042 -80757374 -69085042 -69085042 -69085042 -69085042 -38501500 -38501500 -38501500 -69085042 -69085042 -69085042 -69085042 -80757374 -80757374 -81296691 -81296691 -87611912 -81296691 -81296691 -80757374 -…

Example 3:

Input: 2215 480252862 -719892963 -838881084 -935497539 214695176 -812548888 -600408042 -822133529 -279950699 -106387176 -455001735 -225729400 -345522637 667961077 -162557113 646753004 -941700275 -677795562 -28494733 -559497983 339220809 -282781664 882455840 -48261624 416545484 -433602565 -17139344 574202329 -986757492 -471269602 845509393 271965566 -728312143 595595166 948455637 -371087681 -490526829 467466668 269795030 978821502 -534991635 -167773322 462114113 -246082605 -91609524 409741689 168273549 -694886131 -857694513 449829259 781986407 -199233631 558046442 -254668399 -471114369 657141391 -354776172 -493544703 -482676917 -783442899 429530058 519389641 367574572 -860625662 402156850 461171792 -592944336 703175248 627880503 -18799505 399084761 -749061767 481483316 459665519 -311055344 -309093…
Output: 480252862 -719892963 -719892963 -838881084 -719892963 -812548888 -719892963 -812548888 -719892963 -719892963 -600408042 -600408042 -455001735 -455001735 -345522637 -345522637 -345522637 -455001735 -345522637 -455001735 -345522637 -345522637 -282781664 -282781664 -279950699 -282781664 -279950699 -279950699 -279950699 -282781664 -279950699 -279950699 -279950699 -279950699 -225729400 -279950699 -279950699 -279950699 -225729400 -225729400 -225729400 -225729400 -167773322 -225729400 -167773322 -167773322 -162557113 -167773322 -167773322 -167773322 -162557113 -167773322 -162557113 -167773322 -167773322 -167773322 -167773322 -199233631 -199233631 -225729400 -199233631 -199233631 -167773322 -199233631 -167773322 -167773322 -167773322 -167773322 -162557113 -162557113 -106387176 -162557113 -10638717…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The beacons Middle So Far Puzzle - MEDIUM Coding Problem | CodeTikki