CT61712

Seth's Ledger of marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the temple city of Sunspire as Seth unrolls the day's manifest of marks. The tally will decide the next shipment. 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: 1761 -414352437 762349564 487009821 -848062652 841074972 426166664 -431456394 -45782902 720993718 -269508609 803963959 130268519 869877914 -795793678 431303386 -355144185 -936329039 -583961212 145606714 27918242 -712914837 -512464367 156710062 -610412519 996235254 756211793 899900302 -400175711 -49862599 375716187 -984361376 -652347492 -856920958 -917151635 477076292 -785430147 703691631 -665680546 546062186 737999059 -76849884 263611121 796940929 -284002507 740750038 -429660846 236013927 881784153 -347452032 826471955 5346027 -706543703 -696916158 -121724819 936262894 -453532363 366758161 -935396580 -948793574 -499982214 647084090 -26256589 963184385 -341109347 -6937619 773491380 -210623591 -28990933 348926177 -890617053 263520865 766259477 373059081 -714554790 204424892 -629763276 -32596…
Output: -414352437 -414352437 487009821 -414352437 487009821 426166664 426166664 -45782902 426166664 -45782902 426166664 130268519 426166664 130268519 426166664 130268519 130268519 -45782902 130268519 27918242 27918242 -45782902 27918242 -45782902 27918242 27918242 130268519 27918242 27918242 27918242 27918242 -45782902 -45782902 -49862599 -45782902 -49862599 -45782902 -49862599 -45782902 -45782902 -45782902 -45782902 27918242 -45782902 27918242 -45782902 27918242 27918242 27918242 27918242 27918242 5346027 5346027 -45782902 5346027 -45782902 5346027 -45782902 -45782902 -49862599 -45782902 -45782902 -26256589 -45782902 -26256589 -26256589 -26256589 -28990933 -26256589 -28990933 -26256589 -26256589 -6937619 -26256589 -6937619 -26256589 -6937619 -26256589 -11426796 -26256589 -11426796 -11426796 -693…

Example 2:

Input: 3844 -536079160 783653670 502569980 -854804263 269732665 675601750 205535835 553411091 288549543 254594604 -965127820 422682394 797133677 223657119 834037906 -836437773 -584251443 -935820102 281468790 414833561 -596962337 -279499288 -198873481 -586363825 68182235 26978220 591373314 516816822 -913295528 -423465579 -406664416 -761934140 -581404656 -599269734 -650230545 828649389 208250004 -883348187 244253739 -827926228 477090285 -173377475 -642044761 183249877 17930840 -251521946 -664895556 469264486 -419744688 337420140 513794294 218880314 183258352 816233026 -3680761 195329075 67467170 997504503 -642944586 549554796 581784287 695922120 181835625 -994621586 -628264274 -761894849 982758774 -210554593 707402252 -35954700 -504468537 706378695 397834665 -742335785 223870707 502774528 867673138…
Output: -536079160 -536079160 502569980 -536079160 269732665 269732665 269732665 269732665 288549543 269732665 269732665 269732665 288549543 269732665 288549543 269732665 269732665 254594604 269732665 269732665 269732665 254594604 254594604 223657119 223657119 205535835 223657119 223657119 223657119 205535835 205535835 68182235 68182235 26978220 26978220 26978220 68182235 26978220 68182235 26978220 68182235 26978220 26978220 26978220 26978220 17930840 17930840 17930840 17930840 17930840 26978220 26978220 68182235 68182235 68182235 68182235 68182235 68182235 68182235 68182235 183249877 183249877 183249877 181835625 181835625 68182235 181835625 68182235 181835625 68182235 68182235 68182235 181835625 68182235 181835625 181835625 183249877 181835625 183249877 181835625 183249877 183249877 183258352 18…

Example 3:

Input: 2579 -585920984 948874468 459278495 -187032309 -78828902 118134097 -340954779 373485449 505199425 874570605 -570983872 -387335248 60901429 55314574 505362914 995300185 -931058660 -605916935 -361933789 497437878 -400104510 -214140917 -6293903 240992304 -30493303 549294919 74438829 -455375855 -744928314 -844118237 107399106 695917706 -573073691 -379140514 565575753 665034112 -897240475 -44267952 -955409057 -278874271 -224296888 551205324 123165778 -718151250 -350070449 612054813 800355966 -500423390 -567462126 -776188620 42620047 -64181555 -261753326 -717931159 -191307093 827303325 -46424411 37494821 -419784863 627113154 -747008810 600116902 -770457490 362252429 -513746072 314889555 -983298702 -358573561 655593886 127791568 -133899980 -44848113 -561685095 166530121 299886340 -540113016 -9745…
Output: -585920984 -585920984 459278495 -187032309 -78828902 -78828902 -78828902 -78828902 118134097 118134097 118134097 -78828902 60901429 55314574 60901429 60901429 60901429 55314574 55314574 55314574 55314574 -78828902 -6293903 -6293903 -6293903 -6293903 55314574 -6293903 -6293903 -30493303 -6293903 -6293903 -6293903 -30493303 -6293903 -6293903 -6293903 -30493303 -30493303 -44267952 -44267952 -44267952 -30493303 -44267952 -44267952 -44267952 -30493303 -44267952 -44267952 -78828902 -44267952 -64181555 -64181555 -78828902 -78828902 -78828902 -64181555 -64181555 -64181555 -64181555 -64181555 -64181555 -64181555 -64181555 -64181555 -64181555 -64181555 -78828902 -64181555 -64181555 -64181555 -64181555 -64181555 -64181555 -46424411 -64181555 -64181555 -64181555 -46424411 -46424411 -46424411 -46424411…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.