CT64461

Curator's Ledger of beacons

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the floating docks of Skyharbor as Curator unrolls the day's manifest of beacons. 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: 1581 160165128 342634102 -466348184 746451939 903282422 974077134 -113979000 -717980963 291890271 -986778811 -644139060 -799090838 166196773 481293710 682290269 941105653 197735019 390325051 643145055 683833641 490488381 200228863 -999560046 187904096 -488467588 194960711 -995729790 -671708611 137562888 628430175 703168301 -95333424 -27036483 -581027479 423026265 -44109412 612197386 642468707 -461431687 326692653 -496598767 -192576846 -926964550 367639120 665438115 -372921888 903956404 -256487657 733699926 698496315 -700126968 -43225990 -931272177 591931912 716910905 -928932279 -935892742 886437985 274412336 3453330 777892259 -377369706 608705097 306181402 379053555 1310165 -876375616 142615671 12466192 607572149 479277820 -28158212 -13680482 380698498 537404315 -955238994 500399540 -59887…
Output: 160165128 160165128 160165128 160165128 342634102 342634102 342634102 160165128 291890271 160165128 160165128 -113979000 160165128 160165128 166196773 166196773 197735019 197735019 291890271 291890271 342634102 291890271 291890271 200228863 200228863 197735019 197735019 194960711 194960711 194960711 197735019 194960711 194960711 187904096 194960711 187904096 194960711 194960711 194960711 194960711 194960711 187904096 187904096 187904096 194960711 187904096 194960711 187904096 194960711 194960711 194960711 187904096 187904096 187904096 194960711 187904096 187904096 187904096 194960711 187904096 194960711 187904096 194960711 194960711 197735019 194960711 194960711 187904096 187904096 187904096 194960711 187904096 187904096 187904096 194960711 187904096 194960711 187904096 194960711 187904096…

Example 2:

Input: 2731 180485687 891584802 -272569728 -347669924 -134123056 603016125 -342673341 -574998292 145178055 -918097958 210412307 493864676 60803439 338881030 -332829562 -159087618 797757789 832456685 -87475180 -847709138 442129628 14834781 703721741 113788318 -246460274 206856744 -529032601 479668035 -585026850 -876260017 848402991 -591499238 -572217083 297705191 -246004525 310355792 41020177 549292268 182079528 -393098487 349638585 -492318335 818967810 28328522 753191839 -421748485 698169619 604725268 -46770222 -558194580 -765680643 -100631522 560923749 -289330267 -892862652 94631558 808029294 -259729134 485769091 598890686 -51980854 -162689563 572254341 -919160477 340854282 -14797211 -201240081 710557180 -998222768 928918302 -380189806 417852051 455995057 119750347 -915382684 -502321969 -2795962…
Output: 180485687 180485687 180485687 -272569728 -134123056 -134123056 -134123056 -272569728 -134123056 -272569728 -134123056 -134123056 60803439 60803439 60803439 -134123056 60803439 60803439 60803439 -87475180 60803439 14834781 60803439 60803439 60803439 60803439 60803439 60803439 60803439 14834781 60803439 14834781 14834781 14834781 14834781 14834781 41020177 41020177 60803439 41020177 60803439 41020177 60803439 41020177 60803439 41020177 60803439 60803439 60803439 41020177 41020177 28328522 41020177 28328522 28328522 28328522 41020177 28328522 41020177 41020177 41020177 28328522 41020177 28328522 41020177 28328522 28328522 28328522 28328522 28328522 28328522 28328522 41020177 41020177 41020177 28328522 28328522 14834781 28328522 14834781 14834781 -14797211 -14797211 -46770222 -14797211 -147972…

Example 3:

Input: 1649 394811535 899303448 -661810800 -569991284 261709956 -891000020 -77089327 -59909589 353800669 -734504619 -914474084 576451006 -980592194 -721148990 237769926 243965053 606054560 -460873799 -609860025 -718015163 -930645261 135292213 -57419532 649982604 -88331743 978947405 104339332 812381781 98130847 -944924599 -736217803 -886774152 -382627502 62796097 656777072 -815149846 -680127770 -879362398 -740135550 339124673 -887898632 -544485282 358630875 -442907755 -872872309 187784393 -420886763 -372937243 -771153525 51701261 -627683575 -940450344 -929267394 -26654308 -845261495 744078686 670269616 505330899 -943919995 -985125090 511147325 -127945161 386327889 250588343 -575420578 276251178 -83125234 -555567970 -631034795 -209811427 -702315138 808291797 327231063 558292515 70243290 -541853128 …
Output: 394811535 394811535 394811535 -569991284 261709956 -569991284 -77089327 -77089327 -59909589 -77089327 -77089327 -77089327 -77089327 -569991284 -77089327 -77089327 -59909589 -77089327 -77089327 -460873799 -460873799 -460873799 -77089327 -77089327 -77089327 -77089327 -59909589 -59909589 -57419532 -59909589 -59909589 -77089327 -77089327 -77089327 -59909589 -77089327 -77089327 -88331743 -88331743 -88331743 -88331743 -382627502 -88331743 -382627502 -382627502 -382627502 -382627502 -382627502 -382627502 -382627502 -382627502 -420886763 -420886763 -420886763 -420886763 -420886763 -382627502 -382627502 -382627502 -420886763 -382627502 -382627502 -372937243 -372937243 -372937243 -372937243 -127945161 -372937243 -372937243 -372937243 -372937243 -372937243 -209811427 -209811427 -127945161 -209811427 …

Constraints:

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

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