CT61215

Hidden ledgers Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the gristmill of Rye Hollow. Scribe spreads the ledgers records across the table and picks up a sharp pencil. 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: 3192 531252206 -569469275 555124325 928796967 113526223 -243070080 -863088977 113412688 698387558 -793177004 216609069 183815867 -507045624 -447780500 -848438375 -243119956 244216919 -539038611 -881576792 -464707032 -655435567 -312972462 -563909489 -823774088 -672493089 -524972096 -726901979 986524150 -370557968 -659925608 138139429 433101449 -438288181 -561766276 -138630701 617150551 279090273 -425158151 -414759484 757711439 703316818 113489708 -434102240 981310171 -504412382 315370225 -338617811 -900834621 251018236 963614737 641188580 -512148729 823413378 676755076 -800459402 -188617040 -771605217 -892427804 -287934626 -312049272 -138333130 171248887 532602520 975333934 677732111 143197021 309486323 -671578402 499083869 319620985 -287166771 267813151 868594412 -873331478 -202951352 5356…
Output: 531252206 -569469275 531252206 531252206 531252206 113526223 113526223 113412688 113526223 113412688 113526223 113526223 113526223 113412688 113412688 -243070080 113412688 -243070080 -243070080 -243119956 -243119956 -312972462 -312972462 -447780500 -447780500 -464707032 -464707032 -464707032 -447780500 -464707032 -447780500 -447780500 -438288181 -447780500 -438288181 -438288181 -370557968 -425158151 -414759484 -414759484 -370557968 -370557968 -370557968 -370557968 -370557968 -370557968 -338617811 -370557968 -338617811 -338617811 -312972462 -338617811 -312972462 -312972462 -312972462 -312972462 -312972462 -338617811 -312972462 -312972462 -312049272 -312049272 -287934626 -287934626 -243119956 -243119956 -243070080 -243119956 -243070080 -243070080 -243070080 -243070080 -188617040 -243070080 -…

Example 2:

Input: 3435 -921290543 -301203651 800325299 280859913 798342815 -613638605 -222170899 -187324815 211447450 383027543 -983607006 -148894533 -445299140 -429422425 -619854441 -643505294 74950013 -817643788 -756086310 -467381366 -683027508 57613444 -421629860 -118169881 116906823 -378171260 -288152883 -833631960 -49420396 -719859635 248205020 15009131 -102215447 -166676058 470503886 716179926 932957087 -742549188 -177657730 -689540447 170356494 520158711 -947936705 -890280776 495041803 -135732979 348796025 -662161595 458674431 -298841294 301719121 176202430 -603052789 153052375 840343818 -683727092 45885255 -983555924 566995132 941594356 -176124479 184025185 465045894 -883945269 -880900694 817988382 118497746 755080711 231756578 -109824621 -494230694 303492775 816770795 -725763833 -105343971 88437324…
Output: -921290543 -921290543 -301203651 -301203651 280859913 -301203651 -222170899 -222170899 -187324815 -187324815 -187324815 -187324815 -187324815 -222170899 -222170899 -301203651 -222170899 -301203651 -301203651 -429422425 -429422425 -429422425 -421629860 -421629860 -301203651 -378171260 -301203651 -378171260 -301203651 -378171260 -301203651 -301203651 -288152883 -288152883 -222170899 -222170899 -187324815 -222170899 -187324815 -222170899 -187324815 -187324815 -187324815 -222170899 -187324815 -187324815 -177657730 -187324815 -177657730 -187324815 -177657730 -177657730 -177657730 -177657730 -166676058 -177657730 -166676058 -177657730 -166676058 -166676058 -166676058 -166676058 -148894533 -166676058 -166676058 -166676058 -148894533 -148894533 -135732979 -135732979 -135732979 -135732979 -11816988…

Example 3:

Input: 3680 773358219 -921751781 228614160 424879987 -938230665 -587578336 -716723298 -388711742 371634490 -846985054 89071082 -817629833 535970380 -451366911 788044369 -966897984 334929948 -99169503 625520436 -683034875 -129944404 303343990 -112955435 -208731693 399769135 249612908 -68463345 -379409446 610899873 496682453 -550357036 87519220 -81652724 297540664 347551601 -979979235 120635984 -865637839 581539256 -136011934 -60392506 -993526581 -357368871 -253118223 716057722 444548681 104238668 -200109924 -715443256 -997613105 169450015 -690053649 -875729885 569601865 684555066 -25071086 -547876547 668674029 -591369494 -722474428 -134041636 -587328948 106952353 667729035 -695428104 94424084 -927162421 -198295888 -794791537 -74685108 -851954580 108531166 -253082042 447690971 414172061 -147679933 …
Output: 773358219 -921751781 228614160 228614160 228614160 -587578336 -587578336 -587578336 -388711742 -587578336 -388711742 -587578336 -388711742 -451366911 -388711742 -451366911 -388711742 -388711742 -99169503 -388711742 -129944404 -129944404 -112955435 -129944404 -112955435 -112955435 -99169503 -112955435 -99169503 -99169503 -99169503 -99169503 -81652724 -81652724 -68463345 -81652724 -68463345 -81652724 -68463345 -81652724 -68463345 -81652724 -81652724 -99169503 -81652724 -81652724 -68463345 -81652724 -81652724 -99169503 -81652724 -99169503 -99169503 -99169503 -81652724 -81652724 -81652724 -81652724 -81652724 -99169503 -99169503 -112955435 -99169503 -99169503 -99169503 -99169503 -99169503 -112955435 -112955435 -112955435 -112955435 -112955435 -112955435 -112955435 -99169503 -112955435 -99169503…

Constraints:

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

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