CT59942

The Northern signals of Ivo

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Ivo runs the lighthouse at the ferry landing of Crosswater. Today the books show a list of signals, 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: 3301 824726339 -416572402 814446030 201608207 -503562175 -66210191 -58052573 -206072967 703150564 -925274080 -915095134 555640453 665662139 232821637 343684476 985103842 338525835 -154388275 364792087 -616158324 -818055595 917165837 -757783122 297603638 -385684450 568456807 -610574817 -568024829 -941633097 784772048 -70238070 -758108269 -340419030 -233232554 -546478474 625440824 814464456 -330663299 910840735 -625180405 -355313570 209682461 288532748 -378686672 518961353 795351781 -528801867 79149116 805164635 273053789 977116979 449005009 493392588 -521314211 -511851614 -915256262 -336487739 913262940 358671535 -790653143 -519005545 -726949413 154761573 -29839092 905437218 -897980212 707115009 808906875 -659647645 -345191836 -134241652 -239196284 352195767 -421888095 550979228 -39022444 -…
Output: 824726339 -416572402 814446030 201608207 201608207 -66210191 -58052573 -66210191 -58052573 -66210191 -66210191 -66210191 -58052573 -58052573 201608207 201608207 232821637 201608207 232821637 201608207 201608207 201608207 201608207 201608207 201608207 201608207 201608207 -58052573 -58052573 -58052573 -58052573 -66210191 -66210191 -70238070 -70238070 -70238070 -66210191 -70238070 -66210191 -70238070 -70238070 -70238070 -66210191 -70238070 -66210191 -66210191 -66210191 -66210191 -58052573 -58052573 79149116 79149116 201608207 79149116 79149116 -58052573 -58052573 -58052573 79149116 -58052573 -58052573 -66210191 -58052573 -58052573 -29839092 -58052573 -29839092 -29839092 -29839092 -58052573 -58052573 -66210191 -58052573 -66210191 -58052573 -58052573 -58052573 -58052573 -58052573 -66210191 -580…

Example 2:

Input: 2301 643793596 891150604 133452221 117918615 228512390 -736697817 -366791746 380303193 430242092 -340325992 913199440 -10653702 -428400529 749883623 899567849 845039354 -512580537 -972667685 -431204227 -887847933 703591377 -749317387 161610264 104508261 181285966 -530270799 931388146 797522336 -30418953 816435210 -65795770 -527831304 118881156 -549935729 236871146 -92827958 925054723 959234094 -68617219 625045648 717174268 343015282 -2038075 -884364878 -835737307 464749626 -194475050 495683896 -536029198 503850761 119172322 -981022852 419222101 707944734 -84514630 427403651 -306941507 -479366634 -112990506 161061585 -352145512 140481656 418592641 91254339 386671341 -441724470 675529039 120605431 558397214 -497971327 -917696960 651963092 -131322364 186370930 -520317320 980404625 -117852438 …
Output: 643793596 643793596 643793596 133452221 228512390 133452221 133452221 133452221 228512390 133452221 228512390 133452221 133452221 133452221 228512390 228512390 228512390 133452221 133452221 117918615 133452221 117918615 133452221 117918615 133452221 117918615 133452221 133452221 133452221 133452221 133452221 117918615 118881156 117918615 118881156 117918615 118881156 118881156 118881156 118881156 133452221 133452221 133452221 118881156 118881156 118881156 118881156 118881156 118881156 118881156 119172322 118881156 119172322 119172322 119172322 119172322 119172322 118881156 118881156 118881156 118881156 118881156 119172322 118881156 119172322 118881156 119172322 119172322 120605431 119172322 119172322 119172322 119172322 119172322 119172322 119172322 119172322 118881156 118881156 117918615 …

Example 3:

Input: 1206 633681096 -840388617 -753480354 613855918 679284316 -964254505 -998158755 966870457 -998249586 -688366111 925101925 20771592 -657345460 -960230184 -922338987 -86083195 65036112 499721264 -279670570 137188999 -846895049 14450136 155121096 461143515 392521383 -554839552 468256470 -222040956 890850119 409746722 865672016 -583388751 840086487 -539533731 198344579 20113591 302952662 681755769 -536752546 31687317 157441013 -925351300 -174248258 -721803691 -9538361 995298804 -728918523 680329381 -67396731 86938492 -439242820 -958569123 -768844074 -181955324 -357107528 170245930 -338830770 -500283023 -958342378 -147355206 -306333404 -530536159 -832601053 262937668 -749192001 -158817324 362914771 -992854338 959125445 179454452 -967279291 -983502977 -851859754 -859119875 -249131790 132908340 -4…
Output: 633681096 -840388617 -753480354 -753480354 613855918 -753480354 -753480354 -753480354 -753480354 -753480354 -688366111 -688366111 -657345460 -688366111 -688366111 -688366111 -657345460 -657345460 -279670570 -279670570 -279670570 -279670570 -86083195 -86083195 14450136 -86083195 14450136 -86083195 14450136 14450136 20771592 14450136 20771592 14450136 20771592 20113591 20771592 20771592 20771592 20771592 31687317 20771592 20771592 20113591 20113591 20113591 20113591 20113591 20113591 20113591 20113591 14450136 14450136 -9538361 -9538361 -9538361 -9538361 -67396731 -67396731 -86083195 -86083195 -147355206 -147355206 -147355206 -147355206 -158817324 -147355206 -158817324 -147355206 -147355206 -147355206 -158817324 -158817324 -174248258 -174248258 -174248258 -174248258 -174248258 -158817324 -15…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Northern signals of Ivo - MEDIUM Coding Problem | CodeTikki