CT60702

The Middle So Far at Stormrest

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the cliffside roost of Stormrest, Iris records each signals 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: 3786 623870664 1827844 517966494 735105346 572056186 -619728080 172803110 598077778 -765795185 -822226725 -646578020 -683802899 -161066440 -483824083 605391074 46764332 385738243 -965826776 214436425 848342904 776919886 -271182450 545682022 91190570 946622628 -607532954 -159437108 -347515738 908258721 -436596595 -886527225 261509181 -497086878 -987585764 -388987583 -709611322 36799351 836825523 751721123 265670927 837047213 753254584 834415777 -265407371 828112413 -19464763 -197394581 -758533489 257885509 -509518674 -219758827 -167142146 795319462 575323908 -353059193 367734031 -285621134 334465870 717895361 373481412 -819844089 183955675 -704168685 -268166510 28491644 -552812765 330682869 -359202978 846424614 -14440165 -850156043 799883533 -304488430 -451153381 475265209 -562365254 -41400…
Output: 623870664 1827844 517966494 517966494 572056186 517966494 517966494 517966494 517966494 172803110 172803110 1827844 1827844 -161066440 1827844 1827844 46764332 1827844 46764332 46764332 172803110 46764332 172803110 91190570 172803110 91190570 91190570 46764332 91190570 46764332 46764332 46764332 46764332 1827844 1827844 -159437108 1827844 1827844 36799351 36799351 46764332 46764332 91190570 46764332 91190570 46764332 46764332 36799351 46764332 36799351 36799351 1827844 36799351 36799351 36799351 36799351 36799351 36799351 46764332 46764332 46764332 46764332 46764332 36799351 36799351 28491644 36799351 28491644 36799351 28491644 28491644 28491644 28491644 1827844 28491644 1827844 1827844 -14440165 -14440165 -19464763 -14440165 -19464763 -19464763 -127276443 -127276443 -127276443 -127276443 …

Example 2:

Input: 1979 249909042 977159993 850843011 -823367230 275441627 -742093166 828770013 -253561472 -992483068 -995714864 -333482331 -309292164 -766567244 716930804 -204794404 947837970 988810309 332026060 -181430940 -351494292 -160839846 -239242575 -516079719 -332895713 -679519692 738930931 -754853726 -172443243 843790823 439571265 -594054448 -125202936 -29056053 -686114064 574775817 946342530 772500397 -207523352 903252627 -88203865 -253301626 -972364351 67987118 70456494 -774359259 691956409 828915214 -65131030 -416716571 -595477328 -602893499 889393950 203251498 850460572 -74273174 -216823566 511732590 548390185 467997188 363399013 -588452071 -445661233 -671116783 -584850388 900926531 551206933 884396811 -81094930 -333675543 -922492121 215681898 -834887904 -831838451 -67350536 -166731122 569185510…
Output: 249909042 249909042 850843011 249909042 275441627 249909042 275441627 249909042 249909042 -253561472 -253561472 -309292164 -309292164 -309292164 -253561472 -253561472 -204794404 -204794404 -181430940 -204794404 -181430940 -204794404 -204794404 -239242575 -239242575 -239242575 -239242575 -239242575 -204794404 -204794404 -204794404 -204794404 -181430940 -204794404 -181430940 -181430940 -172443243 -181430940 -172443243 -172443243 -172443243 -181430940 -172443243 -172443243 -172443243 -172443243 -160839846 -160839846 -160839846 -172443243 -172443243 -172443243 -160839846 -160839846 -125202936 -160839846 -125202936 -125202936 -88203865 -88203865 -88203865 -125202936 -125202936 -160839846 -125202936 -125202936 -88203865 -88203865 -88203865 -125202936 -88203865 -125202936 -125202936 -125202936 -1…

Example 3:

Input: 153 271065270 543376908 415949364 343636117 -246591589 -202175399 300897055 -581735006 488655372 55844090 -597324994 975257584 -365535055 -769082632 876165805 807903641 -575112671 504036351 200392628 -666266565 359733532 822377250 630644715 -216149416 -231531227 911753874 406650007 -572942985 -432501728 -331513071 -114978367 -280527314 -779662034 147037665 -277772051 420233214 51426735 -722294553 205645369 -697221306 410462265 -389907371 -957201638 495230898 463825596 228008998 257365748 236368012 -964055344 -199271346 -717631598 -280431325 485403778 299945497 -143601052 409107930 374090250 -376330347 -846750356 349377189 6488351 594498968 -441563518 851131060 529697240 -782211724 884156897 -588612769 16116371 675304279 -732674022 -866346951 -641001904 -210702312 -78509154 -459356178 -9838…
Output: 271065270 271065270 415949364 343636117 343636117 271065270 300897055 271065270 300897055 271065270 271065270 271065270 271065270 55844090 271065270 271065270 271065270 271065270 271065270 200392628 271065270 271065270 300897055 271065270 271065270 271065270 300897055 271065270 271065270 200392628 200392628 55844090 55844090 55844090 55844090 55844090 55844090 51426735 55844090 51426735 55844090 51426735 51426735 51426735 55844090 55844090 147037665 147037665 147037665 55844090 55844090 51426735 55844090 55844090 55844090 55844090 147037665 55844090 55844090 55844090 55844090 55844090 55844090 55844090 147037665 55844090 147037665 55844090 55844090 55844090 55844090 51426735 51426735 16116371 16116371 6488351 6488351 -78509154 6488351 -78509154 6488351 6488351 16116371 6488351 16116371 648…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Middle So Far at Stormrest - MEDIUM Coding Problem | CodeTikki