CT63329

Marble marks Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the galleon yard of Masthead, Indu studies rows of marks entries. One clean number will settle the guild's oldest argument. 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: 40 679513689 -811525274 -778843173 25425379 498426991 -883954029 -878946220 664542678 326113718 627751476 96316317 -785783699 -419924289 26356820 -413708635 893065197 -165064257 -591584362 53448305 702561407 459867426 532916034 -428826755 -374093846 -969559215 134046384 -832993599 -850058296 -64966881 -523742100 -146094102 99345685 575191853 828511742 -260550209 753745613 783703636 487491614 -839851705 199494745
Output: 679513689 -811525274 -778843173 -778843173 25425379 -778843173 -778843173 -778843173 25425379 25425379 96316317 25425379 25425379 25425379 25425379 25425379 25425379 -165064257 25425379 25425379 26356820 26356820 26356820 25425379 25425379 25425379 25425379 -165064257 -64966881 -165064257 -146094102 -146094102 -64966881 -64966881 -64966881 -64966881 25425379 25425379 25425379 25425379

Example 2:

Input: 111 89546008 -372806843 244190031 -196490099 966998357 -585427757 -60799300 971341966 -707981911 356676481 134331511 203353600 -75328483 -251762443 -925968035 -927534946 -925873663 -562911142 845440698 756387145 171879565 -132127367 369990368 -85316345 637591140 -964080426 -701029175 361751625 -789223568 -547910253 886005969 849436511 -480426657 -693600220 825849509 -430247197 -818352030 229121995 -918583676 151486297 997927977 -133600277 544382747 331228046 -659792457 496910574 177259777 -216905290 -79784390 -580312213 -917128505 642586382 -163904221 313998841 -566006965 -276368293 -312413040 942179711 -8509325 -539944503 397943890 194831766 276122362 705166170 -707216427 27088741 404194972 -706092872 294424675 120206174 -796272271 -152966648 -513474770 761199543 28526202 -209961730 -9665…
Output: 89546008 -372806843 89546008 -196490099 89546008 -196490099 -60799300 -60799300 -60799300 -60799300 89546008 89546008 89546008 -60799300 -60799300 -75328483 -75328483 -196490099 -75328483 -75328483 -60799300 -75328483 -60799300 -75328483 -60799300 -75328483 -75328483 -75328483 -75328483 -85316345 -75328483 -75328483 -75328483 -85316345 -75328483 -85316345 -85316345 -85316345 -85316345 -85316345 -75328483 -85316345 -75328483 -75328483 -75328483 -75328483 -60799300 -75328483 -75328483 -79784390 -79784390 -79784390 -79784390 -79784390 -79784390 -85316345 -85316345 -85316345 -79784390 -85316345 -79784390 -79784390 -75328483 -75328483 -75328483 -75328483 -60799300 -75328483 -60799300 -60799300 -60799300 -75328483 -75328483 -75328483 -60799300 -75328483 -75328483 -79784390 -75328483 -75328483 -6…

Example 3:

Input: 2461 608135451 -355232892 48604315 -209876019 -39846091 335568769 125584907 523518385 -268085676 381197851 -964340521 -512877960 965743722 966873463 956337999 -838808997 -525452337 -508698640 365173352 -698609439 -520023325 -787707151 739007744 344428547 -879482550 -797771474 618909061 -822965441 704041717 81366069 723906593 915220851 635518702 -940480800 -166934375 -514940305 -911514964 582746462 -119855927 930584018 942057605 212256942 736960494 -379389882 -347629108 789253807 -283253021 -634307096 -273798658 -544479831 -926655746 -650027731 64547359 164023198 253447116 -509030580 -725102467 628267382 -40856496 863905538 -125436233 -657036182 218958063 479270288 -803625711 -644963016 678506979 -744766980 423164683 341121297 -264909469 -122068844 -714541623 -407023433 -700113150 148089382…
Output: 608135451 -355232892 48604315 -209876019 -39846091 -39846091 48604315 48604315 48604315 48604315 48604315 -39846091 48604315 48604315 125584907 48604315 48604315 -39846091 48604315 -39846091 -39846091 -209876019 -39846091 -39846091 -39846091 -209876019 -39846091 -209876019 -39846091 -39846091 48604315 48604315 81366069 48604315 48604315 -39846091 -39846091 -39846091 -39846091 -39846091 48604315 48604315 81366069 48604315 48604315 48604315 48604315 -39846091 -39846091 -119855927 -119855927 -166934375 -119855927 -119855927 -39846091 -119855927 -119855927 -119855927 -40856496 -40856496 -40856496 -119855927 -40856496 -40856496 -40856496 -119855927 -40856496 -119855927 -40856496 -40856496 -40856496 -119855927 -119855927 -122068844 -122068844 -122068844 -119855927 -122068844 -119855927 -12206884…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Marble marks Middle So Far - MEDIUM Coding Problem | CodeTikki