CT59568

The marks at Scrollkeep

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Jessa runs the dairy at the archive halls of Scrollkeep. Today the books show a list of marks, and the numbers must be worked out before sundown. 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: 1080 -859203651 473777502 -710375100 -576786184 -169559436 823740886 -443445704 77405723 -61589902 -425967326 728849410 542467405 -171964510 -199484746 -478811427 -804133710 -552049484 -302943533 -517374582 334384318 -698691747 -14607556 -284150087 -910146661 -569127983 139358323 757591271 385714410 -32074389 756512680 -555970277 643903246 -961222700 -550607466 107048353 924174965 -28519808 -274794100 -982291908 -411609277 -321738031 90684882 249540892 902189730 -458987335 251799395 -848167063 438631017 -551541004 -675425290 -89513428 -75403500 653474537 973009893 75527607 65391397 -333328247 923488795 200902771 -423063857 -358898200 -571540837 62228146 145688989 -820420959 -935366523 -364549586 791685587 300929552 278856410 -307358081 346629677 -820638882 647733956 -898754768 968070921 -3…
Output: -859203651 -859203651 -710375100 -710375100 -576786184 -576786184 -443445704 -443445704 -169559436 -425967326 -169559436 -169559436 -169559436 -171964510 -171964510 -199484746 -199484746 -302943533 -302943533 -302943533 -302943533 -302943533 -284150087 -302943533 -302943533 -302943533 -284150087 -284150087 -199484746 -199484746 -199484746 -199484746 -199484746 -284150087 -199484746 -199484746 -171964510 -199484746 -199484746 -274794100 -274794100 -274794100 -199484746 -199484746 -199484746 -199484746 -199484746 -199484746 -199484746 -274794100 -199484746 -199484746 -171964510 -171964510 -169559436 -169559436 -169559436 -169559436 -89513428 -169559436 -169559436 -171964510 -169559436 -169559436 -169559436 -171964510 -171964510 -171964510 -169559436 -169559436 -169559436 -169559436 -16955943…

Example 2:

Input: 1768 -20136637 -132686898 619946464 -840668857 -6090254 827990087 58510255 163939631 -338407437 820176841 -464768788 257672938 650442853 915860998 -640169987 -588649865 511692092 159361343 294600070 -172311719 963023324 289894060 -727394242 -396208862 -769049360 -80320950 -178334938 -505902359 -531442521 -593899430 831410135 778186022 16988344 294069984 169255941 141702501 -91682381 -215919460 -986458648 528864452 15999370 -369232353 -377932255 337063888 -364951470 -964170311 -872127715 41571860 306482479 -166286069 -435691815 -529760074 -939879695 411427592 -558514328 -335505919 -601673182 -950697238 672758350 533322249 246269219 -263709264 -726326884 -509384534 336880133 -806793988 -552547574 -398362350 -530909062 202705319 830550805 -563665529 -144077037 -134405469 343944156 779692202 -…
Output: -20136637 -132686898 -20136637 -132686898 -20136637 -20136637 -6090254 -6090254 -6090254 -6090254 -6090254 -6090254 58510255 58510255 58510255 -6090254 58510255 58510255 159361343 58510255 159361343 159361343 159361343 58510255 58510255 -6090254 -6090254 -20136637 -20136637 -80320950 -20136637 -20136637 -6090254 -6090254 16988344 16988344 16988344 -6090254 -6090254 -6090254 15999370 -6090254 -6090254 -6090254 -6090254 -20136637 -20136637 -20136637 -6090254 -20136637 -20136637 -80320950 -80320950 -80320950 -80320950 -91682381 -91682381 -132686898 -91682381 -91682381 -80320950 -91682381 -91682381 -132686898 -91682381 -132686898 -132686898 -166286069 -166286069 -166286069 -132686898 -166286069 -144077037 -144077037 -134405469 -134405469 -132686898 -134405469 -134405469 -144077037 -134405469 -…

Example 3:

Input: 860 296058437 -922000647 -430707177 -227379817 -363772137 -37721884 -772053529 792943783 554224898 137412480 280532135 109118990 -976971157 732658224 -23116508 -772644001 416158915 -124142464 510155714 -70958473 -866111818 -430306529 107923475 105689966 274241192 99066357 -943435282 423988208 -290597765 931644304 -293195341 -223587537 575809521 -490606297 555360891 349882613 -875612629 -407906585 -378289831 98332403 603774634 -791124075 649780767 657512591 -345728176 1812633 734298522 892798167 -84438995 -130956772 -179978486 -989646964 -655203843 131389508 -17207333 -925505930 401432879 966368509 817000709 -495539509 -366423853 -141826033 -261790245 -653396965 391833709 771800242 85119417 933275651 880445340 -610521243 -414221274 356016456 -370438513 -492192838 -416709232 56638318 9411969…
Output: 296058437 -922000647 -430707177 -430707177 -363772137 -363772137 -363772137 -363772137 -227379817 -227379817 -37721884 -37721884 -37721884 -37721884 -23116508 -37721884 -23116508 -37721884 -23116508 -37721884 -37721884 -70958473 -37721884 -37721884 -23116508 -23116508 -23116508 -23116508 -23116508 -23116508 -23116508 -37721884 -23116508 -37721884 -23116508 -23116508 -23116508 -37721884 -37721884 -37721884 -23116508 -37721884 -23116508 -23116508 -23116508 -23116508 1812633 1812633 1812633 -23116508 -23116508 -37721884 -37721884 -37721884 -23116508 -37721884 -23116508 -23116508 -17207333 -23116508 -23116508 -37721884 -37721884 -70958473 -37721884 -37721884 -23116508 -23116508 -17207333 -23116508 -23116508 -23116508 -23116508 -37721884 -37721884 -37721884 -23116508 -37721884 -23116508 -231165…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The marks at Scrollkeep - MEDIUM Coding Problem | CodeTikki