CT60411

Bhanu and the Topaz ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the mulberry rows of Silkmead, Bhanu the customs officer keeps careful count of the ledgers. rebuild the damaged itinerary, 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: 1616 -362769616 -439169298 32194079 -595505896 944287115 -893512323 330147122 34752981 -707702016 -71169935 -447317863 -274269061 249120001 318688001 444122580 339753805 -163141068 -228936544 -358107255 192939631 -34147349 658252295 992754944 898794000 -204577992 752711146 906600185 114600286 -287361078 828866460 368205380 439811761 -467931777 -158111779 39654528 -7285486 -539859379 -882642658 647062188 514658545 683956409 199994739 -472364902 830879087 -798077217 -799905326 203694458 -954667070 191985586 959860000 947208203 798519144 759545708 -825387491 -990791537 -429154094 74831263 546008541 134725208 449146864 -939228641 379171909 538914497 820868614 -247478745 -620723834 -624788296 320747592 244075637 567838834 -898491916 336444717 -415734039 -366415172 675239478 -815746346 -37266707…
Output: -362769616 -439169298 -362769616 -439169298 -362769616 -439169298 -362769616 -362769616 -362769616 -362769616 -362769616 -362769616 -274269061 -274269061 -71169935 -71169935 -71169935 -163141068 -163141068 -163141068 -71169935 -71169935 -34147349 -34147349 -34147349 -34147349 32194079 32194079 32194079 32194079 34752981 34752981 34752981 32194079 34752981 32194079 32194079 -7285486 32194079 32194079 34752981 34752981 34752981 34752981 34752981 32194079 34752981 32194079 34752981 34752981 39654528 39654528 114600286 39654528 39654528 34752981 39654528 39654528 74831263 74831263 74831263 74831263 114600286 114600286 114600286 74831263 74831263 74831263 114600286 114600286 114600286 114600286 114600286 74831263 114600286 74831263 74831263 74831263 98486712 74831263 74831263 39654528 39654528 …

Example 2:

Input: 3193 821726578 -858143440 768258878 -184846290 978698616 -675419170 -429817838 -559303600 -199285415 -380765712 -661640688 459795814 -481429954 194099522 430242122 -420146187 -239796118 743407203 947981101 -521220474 -402527920 -315905696 -594166923 168474428 -784870121 247028095 804224814 381564270 444946376 167201802 858378242 754789169 -735267441 896143924 735154101 -90707225 342770117 862527486 108753454 599245614 -71993785 430248943 -346608314 342179792 -138289361 84334444 -159008539 662230160 -699000769 966919594 890106240 531240638 -403025723 716033112 83289125 569730501 -65038992 919252446 -605249650 309831994 -996275034 -447146417 652189650 413872369 -349446591 915829177 173178857 399287767 589164769 -718084541 -536793755 -784805043 -297589606 583400244 475306440 -311139578 -86470…
Output: 821726578 -858143440 768258878 -184846290 768258878 -184846290 -184846290 -429817838 -199285415 -380765712 -380765712 -380765712 -380765712 -380765712 -199285415 -380765712 -239796118 -239796118 -199285415 -239796118 -239796118 -315905696 -315905696 -315905696 -315905696 -315905696 -239796118 -239796118 -199285415 -199285415 -184846290 -184846290 -184846290 -184846290 167201802 -90707225 167201802 167201802 167201802 167201802 167201802 167201802 167201802 167201802 167201802 108753454 108753454 108753454 108753454 108753454 167201802 167201802 167201802 167201802 167201802 167201802 167201802 167201802 167201802 167201802 167201802 108753454 167201802 167201802 167201802 167201802 168474428 168474428 173178857 168474428 168474428 167201802 167201802 167201802 168474428 167201802 167201802…

Example 3:

Input: 841 580792728 -144772077 -296194487 218299954 -282036952 830669242 265953885 959493520 -344757202 -525618947 -881378862 488418401 161884402 181177154 -288038498 -15766706 52505896 -977311075 363688433 -691269252 379579672 -510555684 958237414 179823094 730367604 460703764 -857677159 876088270 5751230 -309562137 63789245 287399734 -392695930 -615444285 539083469 -625286411 938283995 -597682688 -365280071 212994640 452611531 -320184174 -760275788 -771188856 -173103917 -352548165 348284974 -91713180 -276283155 318841223 199380133 -18723782 309560492 -30125010 -380896730 -801159838 957778675 419256047 -975353984 815844771 -654235031 -718904368 -671369599 630907660 -754499512 -343767185 -26296849 166967075 702452966 208405120 328731684 689505734 -317703382 616426391 -343934629 5000301 -68481034…
Output: 580792728 -144772077 -144772077 -144772077 -144772077 -144772077 218299954 218299954 218299954 -144772077 -144772077 -144772077 161884402 161884402 161884402 -15766706 52505896 -15766706 52505896 -15766706 52505896 -15766706 52505896 52505896 161884402 161884402 161884402 161884402 161884402 52505896 63789245 63789245 63789245 52505896 63789245 52505896 63789245 52505896 52505896 52505896 63789245 52505896 52505896 5751230 5751230 -15766706 5751230 -15766706 -15766706 -15766706 5751230 -15766706 5751230 -15766706 -15766706 -18723782 -15766706 -15766706 -15766706 -15766706 -15766706 -18723782 -18723782 -18723782 -18723782 -30125010 -26296849 -26296849 -18723782 -18723782 -15766706 -15766706 -15766706 -15766706 -15766706 -15766706 -15766706 -18723782 -15766706 -15766706 5000301 5000301 50003…

Constraints:

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

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