CT62150

Theron's Middle So Far Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

In the mountain city of Highreach, Theron the bookkeeper keeps careful count of the signals. Prove the quality of the harvest, every figure matters. 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: 3837 -97507892 523587025 902036231 -612264635 -59704244 792979021 143865611 -80176128 -637515137 659926314 -363581268 -335548283 463351242 67281215 982230796 560443277 -944331960 -311269668 -165224235 -597729126 455720731 423669987 -134020396 -662822576 816572526 756784791 -946420756 82239919 564338900 -811433044 996524577 -237546375 -10790379 759006504 683438371 817962327 -76956265 874383809 507545604 175019560 607206602 788232815 -810705107 10362571 722673459 -308959037 -719573758 -932841643 513220765 530588199 -775394654 -503840676 571714377 488088254 -857489266 572238768 -353959060 628462148 -128128801 68349598 -316000138 -414239198 -133191661 99134695 -260708331 -456464886 -840432223 -414774694 -624261944 914290453 -525714785 443730945 261226029 438710075 153432521 411893243 -82987661…
Output: -97507892 -97507892 523587025 -97507892 -59704244 -59704244 143865611 -59704244 -59704244 -59704244 -59704244 -80176128 -59704244 -59704244 67281215 67281215 67281215 -59704244 -59704244 -80176128 -59704244 -59704244 -59704244 -80176128 -59704244 -59704244 -59704244 -59704244 67281215 -59704244 67281215 -59704244 -10790379 -10790379 67281215 67281215 67281215 67281215 82239919 82239919 143865611 143865611 143865611 82239919 143865611 82239919 82239919 67281215 82239919 82239919 82239919 67281215 82239919 82239919 82239919 82239919 82239919 82239919 82239919 68349598 68349598 67281215 67281215 67281215 67281215 10362571 10362571 -10790379 -10790379 -10790379 -10790379 -10790379 10362571 10362571 67281215 67281215 67281215 10362571 10362571 10362571 67281215 67281215 67281215 67281215 683495…

Example 2:

Input: 1156 497235132 901728832 -541704351 -413047778 -73198688 827171378 503033348 -135053085 731386760 519072749 -860111875 -359969984 818784661 -907428573 121862133 -59758346 554509978 293172041 -945671283 323413463 157762285 -872882875 -364487681 -39184553 -81007124 998838864 -263845890 -52710007 -604331791 690419197 -485302518 -575950503 982481417 -986422069 786006703 -207783377 -33549749 -545297147 752849701 -871814978 553113283 522847240 88496077 561191634 729447829 -759010542 -906625219 -996998670 875069443 474303708 55552327 -992817738 -709644294 108403995 -598463035 956386983 -877157125 554590577 517170844 880101031 179569910 -500704382 -652313170 33997444 -776437891 -365350872 -964622973 -72956279 -811954301 -806080486 -616455965 386875318 701326764 -996008665 -524221227 -704922707 -95…
Output: 497235132 497235132 497235132 -413047778 -73198688 -73198688 497235132 -73198688 497235132 497235132 497235132 -73198688 497235132 -73198688 121862133 -59758346 121862133 121862133 121862133 121862133 157762285 121862133 121862133 -39184553 -39184553 -39184553 -39184553 -52710007 -52710007 -52710007 -52710007 -59758346 -52710007 -59758346 -52710007 -59758346 -52710007 -59758346 -52710007 -59758346 -52710007 -52710007 -39184553 -39184553 -33549749 -39184553 -39184553 -52710007 -39184553 -39184553 -33549749 -39184553 -39184553 -39184553 -39184553 -39184553 -39184553 -39184553 -33549749 -33549749 55552327 -33549749 -33549749 -33549749 -33549749 -39184553 -39184553 -52710007 -52710007 -59758346 -59758346 -59758346 -52710007 -59758346 -59758346 -72956279 -72956279 -73198688 -73198688 -73198688 …

Example 3:

Input: 377 -616054103 584403199 472724745 633290527 26853756 325442679 969439212 -689834657 -643695906 -441025044 62786546 -697388357 -344840074 923098348 -226467100 617698141 -726641752 -592843761 223534550 770095146 -504478215 -643834859 -99780498 -223022212 131998441 -321668362 -661798253 699861851 -136046131 -269028934 -229140064 494816622 -335097551 -288212958 723806461 174691439 -352986512 -653739229 -453517155 -51823213 944115145 -649227835 -870355925 -337777612 710914379 647382764 949410884 926395291 168729022 8086731 110949124 521545789 188091323 -389336024 516347049 924125137 810821626 445195163 896312046 78456924 -463964531 314697255 -327910052 -462982279 -168466896 -206889015 -868909680 -899674484 376378790 40508133 -925709490 609373790 108060490 398868233 -455665236 768483065 1412635…
Output: -616054103 -616054103 472724745 472724745 472724745 325442679 472724745 325442679 325442679 26853756 62786546 26853756 26853756 26853756 26853756 26853756 26853756 -226467100 26853756 26853756 26853756 -226467100 -99780498 -223022212 -99780498 -223022212 -223022212 -223022212 -136046131 -223022212 -223022212 -223022212 -223022212 -226467100 -223022212 -223022212 -223022212 -226467100 -226467100 -226467100 -223022212 -226467100 -226467100 -229140064 -226467100 -226467100 -223022212 -223022212 -136046131 -136046131 -99780498 -99780498 -51823213 -99780498 -51823213 -51823213 8086731 8086731 26853756 26853756 26853756 26853756 26853756 8086731 8086731 -51823213 -51823213 -99780498 -51823213 -51823213 -51823213 -51823213 8086731 8086731 8086731 8086731 26853756 8086731 8086731 8086731 26853756 …

Constraints:

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

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