CT57186

The Middle So Far of the Crimson beacons

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the gull cliffs of Screech Point opens only for a perfect tally of beacons. Vani means to find out. 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: 3492 -631266067 272243039 186895439 -790889554 160007730 -240411049 873923718 -974398626 255214032 148543564 322202778 -722134268 -508499410 735069124 6613079 -493613770 -377737560 774567896 106183171 174171224 -803235377 697227616 -734269795 938616547 -883885718 -833921628 -363796466 564508508 -689951361 957066706 -65046858 174002706 -645817664 -251575470 -308532927 742036505 -652964817 340213783 -595090375 -164532480 -955758425 -740693130 716010624 -152372265 363399898 721232150 -84826181 729714123 941032320 -366139852 675918789 -751732290 827708794 77333052 596279471 226561420 -330929621 -606194277 829466963 874189931 899594794 720914285 -865453701 -349002714 -468200132 962323967 -767029392 925066443 -349944030 621002455 -184345727 -609709726 -384598037 377847309 -968519665 -730309333 -…
Output: -631266067 -631266067 186895439 -631266067 160007730 -240411049 160007730 -240411049 160007730 148543564 160007730 148543564 148543564 148543564 148543564 6613079 6613079 6613079 106183171 106183171 106183171 106183171 106183171 106183171 106183171 6613079 6613079 6613079 6613079 6613079 6613079 6613079 6613079 -65046858 -65046858 -65046858 -65046858 -65046858 -65046858 -164532480 -164532480 -240411049 -164532480 -164532480 -152372265 -152372265 -84826181 -84826181 -65046858 -84826181 -65046858 -84826181 -65046858 -65046858 6613079 6613079 6613079 -65046858 6613079 6613079 77333052 77333052 77333052 6613079 6613079 6613079 6613079 6613079 6613079 6613079 6613079 -65046858 -65046858 -65046858 -65046858 -84826181 -84826181 -152372265 -152372265 -164532480 -152372265 -152372265 -84826181 -112…

Example 2:

Input: 753 207758783 397278935 -808620484 778832033 664425676 -911812057 298218336 -701837335 -767357141 -665890761 -563424519 -512857420 203637162 548151742 739238035 -663832838 567780552 -130821892 -812894153 -315190152 697282073 -156122337 -117651969 -270894539 -941666779 88093867 -572542220 -511236174 -541138613 661061584 423924828 369012836 -51393237 -846163912 -729379986 -794875901 -437430828 225545614 289571745 455305517 -732840717 698555575 583973372 648766969 -760324485 -234353092 -732021743 983067411 -373615065 585480131 123088256 332153950 994640247 852137172 779127444 490354957 -390422392 466178680 -298715841 -11363318 -513516915 461461621 -515445027 -111382811 -711873709 160068265 660170418 -413671130 632677387 751797274 -834361163 -952175176 659640958 -189212683 -886236531 -43218667…
Output: 207758783 207758783 207758783 207758783 397278935 207758783 298218336 207758783 207758783 -665890761 -563424519 -563424519 -512857420 -512857420 203637162 -512857420 203637162 -130821892 -130821892 -315190152 -130821892 -156122337 -130821892 -156122337 -156122337 -156122337 -156122337 -270894539 -270894539 -270894539 -156122337 -156122337 -130821892 -156122337 -156122337 -270894539 -270894539 -270894539 -156122337 -156122337 -156122337 -156122337 -130821892 -130821892 -130821892 -156122337 -156122337 -156122337 -156122337 -156122337 -130821892 -130821892 -117651969 -117651969 -51393237 -51393237 -51393237 -51393237 -51393237 -51393237 -51393237 -51393237 -51393237 -111382811 -111382811 -111382811 -51393237 -111382811 -51393237 -51393237 -51393237 -111382811 -51393237 -111382811 -111382811 …

Example 3:

Input: 2265 739364678 360018491 712386052 860334307 -859963391 44605090 578772927 -790615580 -801064345 846358577 -510998426 270453855 595596772 850235824 541225084 -457560560 759278484 -453614319 524944285 -722339213 895405045 -678366762 -471505641 202523380 935230286 -628734534 -373096753 -59834067 778729432 592659193 -623521139 -848810264 789005231 399975114 783411414 -774817054 457105537 -539347963 -779960544 -971461962 661829626 -155881310 739790808 -238652636 -775178690 902703333 351327753 233073281 -495225024 -432139298 -222538878 731685220 -397455433 -767756494 686083597 -281749709 508686666 -468481461 213067279 -516470879 -733231526 -998042026 -655122319 771354359 -204734407 -770396777 333747350 781101406 977101497 -452692866 80093106 -653289800 485542059 -822191551 -610591008 606343126 …
Output: 739364678 360018491 712386052 712386052 712386052 360018491 578772927 360018491 360018491 360018491 360018491 270453855 360018491 360018491 541225084 360018491 541225084 360018491 524944285 360018491 524944285 360018491 360018491 270453855 360018491 270453855 270453855 202523380 270453855 270453855 270453855 202523380 270453855 270453855 360018491 270453855 360018491 270453855 270453855 202523380 270453855 202523380 270453855 202523380 202523380 202523380 270453855 233073281 233073281 202523380 202523380 202523380 202523380 44605090 202523380 44605090 202523380 44605090 202523380 44605090 44605090 -59834067 -59834067 -59834067 -59834067 -155881310 -59834067 -59834067 44605090 -59834067 44605090 -59834067 44605090 -59834067 -59834067 -59834067 44605090 44605090 80093106 44605090 80093106 44…

Constraints:

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

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