CT60536

Kabir's Middle So Far Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the boar woods of Tuskmore; Kabir weighs the day's marks manifests and starts the calculations. 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: 604 -443203714 438762552 335597143 -837637416 -932495599 751295962 594477297 -186714984 871083274 -44081065 692488269 394989516 828936718 -227972735 -26767545 930733216 -21152581 163270185 713520598 -480611081 -244860134 -952303854 -456957665 -112428177 390116814 643309088 -481974355 -176477804 -216121885 -647095177 718965314 -847556335 -835240096 174935292 396433045 -430338819 114590580 -36332597 -115134233 -224663033 998583814 -651590356 745460868 -440995777 167497382 -115313856 -318270058 -973302302 -54416065 -259420118 -388353803 217682554 -471549951 203396691 -1522939 565546575 203178818 700869019 756125766 842353801 198503676 784774201 -959379283 -731414418 -752136892 629359524 844527732 809112851 -943040491 170357500 -593235095 855683375 54227930 790958971 -278937475 491792761 72429…
Output: -443203714 -443203714 335597143 -443203714 -443203714 -443203714 335597143 -186714984 335597143 -44081065 335597143 335597143 394989516 335597143 335597143 335597143 335597143 163270185 335597143 163270185 163270185 -21152581 -21152581 -26767545 -21152581 -21152581 -21152581 -26767545 -26767545 -44081065 -26767545 -44081065 -44081065 -44081065 -26767545 -44081065 -26767545 -36332597 -36332597 -44081065 -36332597 -44081065 -36332597 -44081065 -36332597 -44081065 -44081065 -112428177 -54416065 -112428177 -112428177 -112428177 -112428177 -112428177 -54416065 -54416065 -44081065 -44081065 -36332597 -36332597 -26767545 -26767545 -26767545 -36332597 -36332597 -36332597 -26767545 -26767545 -26767545 -26767545 -26767545 -26767545 -21152581 -21152581 -21152581 -21152581 -1522939 -21152581 -1522939 …

Example 2:

Input: 3080 764625958 232478336 498101946 -301988369 677880374 -709783784 -969058280 909877512 295564530 889856149 796261849 726325447 -936374478 476781491 738882799 -892083888 -782963582 -849401850 -684801716 -622181418 -694755386 689041604 -976259528 -162777082 -872746011 295247288 -885354336 -950980118 -458307424 146691182 -56345768 375473709 -922931103 184347202 349180843 53720431 -467234091 551224277 429965612 -332016708 -410100070 -743144853 -457531260 -795852487 -82567034 -319401774 -302297033 -238307625 732329990 -641346767 294535286 -147618874 -910026476 132194777 50512603 -75318350 57128390 -194144712 -431279925 804899607 810415706 -165773926 -990123775 -100028024 695797288 2186243 473875184 -513300297 196490618 364270343 277802322 -944115496 778903509 858161999 770588925 -804539971 -99…
Output: 764625958 232478336 498101946 232478336 498101946 232478336 232478336 232478336 295564530 295564530 498101946 498101946 498101946 476781491 498101946 476781491 476781491 295564530 295564530 232478336 232478336 232478336 232478336 -162777082 -162777082 -162777082 -162777082 -301988369 -301988369 -301988369 -162777082 -162777082 -162777082 -162777082 -56345768 -56345768 -56345768 -56345768 53720431 -56345768 -56345768 -162777082 -162777082 -301988369 -162777082 -301988369 -301988369 -301988369 -238307625 -301988369 -238307625 -238307625 -238307625 -238307625 -162777082 -162777082 -147618874 -162777082 -162777082 -162777082 -147618874 -162777082 -162777082 -162777082 -147618874 -147618874 -100028024 -147618874 -100028024 -100028024 -82567034 -100028024 -82567034 -82567034 -75318350 -82567034 …

Example 3:

Input: 1273 555074128 -469839503 -578415612 -12640835 623524961 -839346760 988339941 -337344911 46137192 -815272769 902812062 378420926 782458218 896548997 294283048 -403503606 524037668 -793146842 -648638185 255300261 -186323124 -43364541 -490002453 -58627946 13187028 -790584154 -101647491 -989148993 -338648308 -515001544 -596841037 510092193 195454265 -522492439 -695211803 739671124 -666982591 870546595 -687949954 732907324 930726053 330350810 889797050 419400886 -763222900 -178044836 -295662803 217031845 -353359257 68631324 119051370 948331204 -275396340 -815159801 -717012438 -891676529 494087347 748457407 -186837977 193246548 233213520 924697236 -463762416 285113768 243834386 -998344564 -79550536 569327241 -853391994 775791657 311763831 637960155 -494363171 97728065 -639715667 -266740601 -790…
Output: 555074128 -469839503 -469839503 -469839503 -12640835 -469839503 -12640835 -337344911 -12640835 -337344911 -12640835 -12640835 46137192 46137192 294283048 46137192 294283048 46137192 46137192 46137192 46137192 -12640835 -12640835 -43364541 -12640835 -43364541 -43364541 -58627946 -58627946 -101647491 -101647491 -101647491 -58627946 -101647491 -101647491 -101647491 -101647491 -101647491 -101647491 -101647491 -58627946 -58627946 -43364541 -43364541 -43364541 -58627946 -58627946 -58627946 -58627946 -58627946 -43364541 -43364541 -43364541 -58627946 -58627946 -101647491 -58627946 -58627946 -58627946 -58627946 -43364541 -43364541 -43364541 -43364541 -12640835 -43364541 -43364541 -43364541 -43364541 -43364541 -12640835 -12640835 -12640835 -12640835 -12640835 -43364541 -43364541 -58627946 -43364541 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Kabir's Middle So Far Ledger - MEDIUM Coding Problem | CodeTikki