CT58405

Ulmar's ledgers Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the coastal hub of Tidewater as Ulmar unrolls the day's manifest of ledgers. 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: 3629 642313755 763692302 -491559742 -346591969 586779513 -438233884 -860605221 243913164 -171811097 874710539 -732189038 184358847 186168505 -11151026 -215072596 958858191 -378051986 -498615141 255290493 615479276 -9674652 34638753 -642673774 660841854 304915719 -412888864 -356498309 -551277259 819545882 666493832 150169840 -723450490 -160306510 -73842899 -981761092 -944446186 -132890444 -506544781 -818364102 694776829 614966204 27443216 170121436 -900455299 408261443 603951867 338950558 669872110 -241789478 993550358 -690780803 -903147530 134518584 522098229 31411273 22082592 408765991 -679138104 -98076397 827332752 -370888700 990961877 -125611028 -157528244 -977432371 -768502819 557076591 841053327 -299315168 23282311 -22515337 541171200 913771467 2516610 603137086 -220824086 -457309218 …
Output: 642313755 642313755 642313755 -346591969 586779513 -346591969 -346591969 -346591969 -171811097 -171811097 -171811097 -171811097 184358847 -11151026 -11151026 -11151026 -11151026 -171811097 -11151026 -11151026 -9674652 -9674652 -9674652 -9674652 34638753 -9674652 -9674652 -11151026 -9674652 -9674652 34638753 -9674652 -9674652 -11151026 -11151026 -73842899 -73842899 -132890444 -132890444 -132890444 -73842899 -73842899 -11151026 -73842899 -11151026 -11151026 -9674652 -9674652 -9674652 -9674652 -9674652 -11151026 -9674652 -9674652 27443216 22082592 27443216 22082592 22082592 22082592 22082592 22082592 22082592 -9674652 -9674652 -11151026 -9674652 -9674652 -9674652 -9674652 -9674652 -9674652 22082592 2516610 22082592 2516610 2516610 2516610 2516610 2516610 22082592 2516610 2516610 -9674652 -967…

Example 2:

Input: 2482 6536437 -308402590 124001988 755527251 57691599 780842209 310266550 773984849 -384385283 943047331 995952582 -86024064 -524212354 -453611177 -542962722 -87914861 -788529839 478703574 -944177205 -352218511 -530493036 -457670537 434519853 -874774678 -873583222 -28604812 145038240 675254189 -832482679 -420155836 -975319117 -376071778 31240245 5088207 -568503822 -415455391 -616323206 83173348 893562658 -530389791 840975784 418527124 -121547631 -865692607 -759186009 -632910802 -728547820 327169743 -594764224 920487088 -915763979 -770845555 -354349853 -804567491 -504930640 -879070434 -796140467 936615846 663368567 -381515574 -374297683 -109064751 186566505 71511441 -40272519 720003317 -143541966 521623202 -292412201 -518207142 -113461611 827838734 598882391 -400354448 -150171599 317659973 1…
Output: 6536437 -308402590 6536437 6536437 57691599 57691599 124001988 124001988 124001988 124001988 310266550 124001988 124001988 57691599 57691599 6536437 6536437 6536437 6536437 -86024064 -86024064 -87914861 -86024064 -87914861 -87914861 -87914861 -86024064 -86024064 -86024064 -87914861 -87914861 -308402590 -87914861 -87914861 -87914861 -308402590 -308402590 -308402590 -87914861 -308402590 -87914861 -87914861 -87914861 -121547631 -121547631 -308402590 -308402590 -308402590 -308402590 -308402590 -308402590 -352218511 -352218511 -354349853 -354349853 -376071778 -376071778 -376071778 -354349853 -376071778 -374297683 -374297683 -354349853 -354349853 -352218511 -352218511 -308402590 -308402590 -292412201 -308402590 -292412201 -292412201 -143541966 -292412201 -150171599 -150171599 -143541966 -1501715…

Example 3:

Input: 3795 -453787515 -115861133 139902720 -904518137 537605323 -631635331 -649027076 820400756 -891057907 -800869222 -653962165 -217339061 353009972 -173941701 880172559 -245533154 -380229330 -303567751 -191123740 414858509 -337444048 545459946 -737244123 615423899 404410023 -185543331 618248923 84037010 842608339 -420097323 -208266848 484260387 -668650359 515849104 371950007 181592223 -696143059 987506448 656313581 -171833625 -223781138 68429158 -410838477 759660883 106458258 -710435498 -740732296 581796948 -389557197 -794877644 53718471 191116982 -334543212 115017968 -277493147 -479123918 955635102 -748238435 -595270487 -518532009 -965903232 -694584094 -81822322 -361816991 295284917 752094985 -278610807 -160330407 745682216 -107924011 -934531162 985197791 686153481 -630690117 -74862445 -87272…
Output: -453787515 -453787515 -115861133 -453787515 -115861133 -453787515 -453787515 -453787515 -453787515 -631635331 -631635331 -631635331 -453787515 -453787515 -217339061 -245533154 -245533154 -303567751 -245533154 -245533154 -245533154 -245533154 -245533154 -245533154 -217339061 -217339061 -191123740 -191123740 -185543331 -191123740 -191123740 -191123740 -191123740 -191123740 -185543331 -185543331 -185543331 -185543331 -173941701 -173941701 -173941701 -173941701 -173941701 -173941701 -171833625 -173941701 -173941701 -173941701 -173941701 -185543331 -173941701 -173941701 -173941701 -173941701 -173941701 -185543331 -173941701 -185543331 -185543331 -191123740 -191123740 -208266848 -191123740 -208266848 -191123740 -191123740 -191123740 -191123740 -185543331 -185543331 -185543331 -185543331 -1739417…

Constraints:

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

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