CT61093

The Jasper ledgers of Arjun

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the observatory of Starfall, Arjun records each ledgers in a worn leather ledger. The guild wants answers, not guesses. 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: 2997 -639678372 724694040 -376778616 -627675435 -131386748 424728689 -572537030 353361104 106988263 384615851 988800944 -243137803 -606861932 300631975 651778850 -552523318 914172331 -149899971 303176513 601381611 147256017 -343369422 -479429704 627650245 -386583849 546409849 -504403257 668228353 577171224 894316895 393088494 656210888 -670105780 423479293 120772096 764273396 -939312075 466055005 806463251 -210562076 -533998888 -253189115 -664541067 -452693298 -857396931 -626527176 -720198307 873314004 792211397 -760396714 366197382 -771701371 -48744960 561651251 221425863 286396265 -325307865 652028444 842006158 351101338 764117196 -486072547 282806167 559109650 870551777 -380347517 -816859737 -589148264 299172953 660642173 171312895 665133725 878788271 483816559 -578279106 895826486 3391…
Output: -639678372 -639678372 -376778616 -627675435 -376778616 -376778616 -376778616 -376778616 -131386748 -131386748 106988263 -131386748 -131386748 -131386748 106988263 -131386748 106988263 -131386748 106988263 106988263 147256017 106988263 106988263 106988263 106988263 106988263 106988263 106988263 147256017 147256017 300631975 300631975 300631975 300631975 300631975 300631975 300631975 300631975 303176513 300631975 300631975 147256017 147256017 120772096 120772096 106988263 106988263 106988263 120772096 106988263 120772096 106988263 106988263 106988263 120772096 120772096 120772096 120772096 147256017 147256017 221425863 147256017 221425863 221425863 282806167 221425863 221425863 147256017 221425863 221425863 221425863 221425863 282806167 282806167 282806167 282806167 286396265 286396265 28639…

Example 2:

Input: 1375 252102961 543165301 629571404 885799975 204660919 176086935 157238281 975917952 -280760454 -452627840 -921001486 32248141 249174627 -703327680 596378728 -934114933 332592593 -501908451 -368868779 -27775285 -993836792 255697070 -981244852 -241917007 -934843916 819696722 179892659 -19186411 563229717 -748095328 916251958 9354036 -152459959 1803366 908767891 -403850539 186786026 108389185 -726125546 528494830 -782374583 374876094 918062156 -32725967 -918208031 625188056 230526637 548083786 -499476929 -841691925 241435720 606190679 67678561 -407959064 -683712762 -868809955 989978839 292622846 198520409 -89329623 722960316 -550254705 304814852 87261704 80691883 -689308291 -519085948 -102525918 792395444 -777969075 -688943516 -620573650 -733464057 773063841 -271424356 182069810 241972448 24…
Output: 252102961 252102961 543165301 543165301 543165301 252102961 252102961 252102961 252102961 204660919 204660919 176086935 204660919 176086935 204660919 176086935 204660919 176086935 176086935 157238281 157238281 157238281 157238281 32248141 32248141 32248141 157238281 32248141 157238281 32248141 157238281 32248141 32248141 9354036 32248141 9354036 32248141 32248141 32248141 32248141 32248141 32248141 108389185 32248141 32248141 32248141 108389185 108389185 108389185 32248141 108389185 108389185 108389185 67678561 67678561 32248141 67678561 67678561 108389185 67678561 108389185 67678561 108389185 87261704 87261704 80691883 80691883 67678561 80691883 67678561 67678561 32248141 32248141 32248141 32248141 32248141 67678561 67678561 80691883 67678561 67678561 67678561 67678561 32248141 67678561 6…

Example 3:

Input: 1000 -888988671 -629769582 69750692 -540436639 -687467476 436572965 789548785 545271697 690951088 -407394811 -115717539 -975942352 925626141 73455012 -876570645 -588241706 247943386 -71463158 755571500 -652174029 -515281367 -742130006 -685886374 69989206 984096358 180888537 650191240 793572616 -250358917 -969413979 -464686095 499540279 -270730805 -762497149 -222182921 -285774840 -482827238 -658243238 105691811 -45523257 877072211 223582333 -391311008 176613749 363330491 787757518 768529164 -335194224 -868779707 521664409 661301237 -713258495 -545080774 -575401922 -791552881 -43766736 988244057 -164515963 368680052 696044260 -430262597 -762873260 -139662984 -903883819 716611431 128675611 10306312 754659950 258868153 -206530677 734147711 683942877 546774489 166435849 258930741 -548479823 -66…
Output: -888988671 -888988671 -629769582 -629769582 -629769582 -629769582 -540436639 -540436639 69750692 -407394811 -115717539 -407394811 -115717539 -115717539 -115717539 -407394811 -115717539 -115717539 -71463158 -115717539 -115717539 -407394811 -407394811 -407394811 -115717539 -115717539 -71463158 -71463158 -71463158 -115717539 -115717539 -115717539 -115717539 -250358917 -222182921 -250358917 -250358917 -270730805 -250358917 -250358917 -222182921 -222182921 -222182921 -222182921 -115717539 -115717539 -71463158 -115717539 -115717539 -115717539 -71463158 -115717539 -115717539 -222182921 -222182921 -222182921 -115717539 -164515963 -115717539 -115717539 -115717539 -164515963 -139662984 -164515963 -139662984 -139662984 -115717539 -115717539 -71463158 -115717539 -71463158 -71463158 -45523257 -45523257…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Jasper ledgers of Arjun - MEDIUM Coding Problem | CodeTikki