CT65204

The Middle So Far of the Wild signals

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Nyssa runs the print shop at the fox den of Rustwood. 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: 3345 234285139 46716562 -677984479 -74814119 -683025645 70334857 -884024375 -820597636 497239725 -962256897 -642001061 -57321740 978384708 -878318750 197948045 835584434 -854050039 404328083 -823126715 -534982283 -104766995 255383451 -179478677 44532099 914826984 139375619 859620998 -786296161 -948489521 -567056055 447500466 207246964 241105687 241329336 -603571264 -594939999 112635720 440576324 414837696 -104252849 -919664445 741373495 484854198 -525346285 15403482 330566142 -781768156 -589459741 -495439044 494914164 922622094 275925511 222952053 431031267 142797441 -411149711 -867983489 539660428 835308230 -312938910 777610959 -674467617 -985909122 775534847 749565476 -756517250 -247949362 -612873150 659484099 -163244148 -808574286 -722733999 -344179253 -848720540 -335373400 -530292125 -…
Output: 234285139 46716562 46716562 -74814119 -74814119 -74814119 -74814119 -677984479 -74814119 -677984479 -642001061 -642001061 -74814119 -642001061 -74814119 -74814119 -74814119 -74814119 -74814119 -534982283 -104766995 -104766995 -104766995 -104766995 -74814119 -74814119 -57321740 -74814119 -74814119 -104766995 -74814119 -74814119 -57321740 -57321740 -57321740 -74814119 -57321740 -57321740 44532099 -57321740 -57321740 -57321740 44532099 -57321740 15403482 15403482 15403482 -57321740 -57321740 -57321740 15403482 15403482 44532099 44532099 46716562 44532099 44532099 44532099 46716562 44532099 46716562 44532099 44532099 44532099 46716562 44532099 44532099 15403482 44532099 15403482 15403482 -57321740 -57321740 -74814119 -74814119 -104252849 -104252849 -104252849 -74814119 -74814119 -74814119 -748…

Example 2:

Input: 1869 -626458926 -386480784 -860517258 -353374938 892915342 -134513646 -260245608 -648973183 191260472 416555915 155665919 95007232 -77283523 210245768 645084028 847441494 -316435347 -424994372 -991969218 -808018888 -183810684 749508891 -913856680 107253080 -84691475 -795397031 -766564799 -181471040 -297544784 185769439 -634025066 459458377 829417106 806205294 -981879447 471544189 -541254978 238185224 -577133951 2516747 -49902541 667166897 -554203497 -603738755 87158439 -11761101 940319341 -913343793 -88005414 479530543 -658107962 967202345 -18462333 565564129 781978238 380579250 -24774821 314943174 -992471387 -303900515 919942848 -95892250 -595153822 447085967 292328812 -126846593 -765338893 748464275 212751987 -839265685 163198062 -389767324 -978888956 151446783 -503596782 -635402869 7846…
Output: -626458926 -626458926 -626458926 -626458926 -386480784 -386480784 -353374938 -386480784 -353374938 -353374938 -260245608 -260245608 -134513646 -134513646 -77283523 -77283523 -77283523 -134513646 -134513646 -260245608 -183810684 -183810684 -183810684 -183810684 -134513646 -183810684 -183810684 -183810684 -183810684 -183810684 -183810684 -183810684 -181471040 -181471040 -181471040 -181471040 -181471040 -181471040 -181471040 -181471040 -134513646 -134513646 -134513646 -181471040 -134513646 -134513646 -84691475 -134513646 -88005414 -88005414 -88005414 -88005414 -84691475 -84691475 -77283523 -77283523 -49902541 -49902541 -49902541 -77283523 -49902541 -77283523 -77283523 -77283523 -49902541 -77283523 -77283523 -77283523 -49902541 -77283523 -49902541 -77283523 -77283523 -77283523 -77283523 -84691…

Example 3:

Input: 1114 -896763529 945739817 496201670 25836495 55948321 -618596479 550186505 -286719714 80557941 659284315 -443280895 121562851 811786475 -690135163 -95489192 624907257 799234134 -187199231 671303022 -667547968 746458729 -250113354 -95734530 -30775639 -259571633 859677122 918124406 967037485 819657858 -828771720 -983217435 819393019 495766244 -827075220 49138326 871163457 351014862 -272681412 -479427575 954733628 -866629063 -458544642 265709955 516921104 814426368 689036107 -482414858 587946763 816613486 389992870 -329124833 -550509162 212405591 -315080776 -607084713 491467713 -568734363 -94434046 839175448 426241922 783223439 767774438 873224532 659620032 311111802 -110414859 -402357770 833810673 364525223 534175413 -294890948 660589232 833642589 -986069150 -301609123 523347370 -773636747 -…
Output: -896763529 -896763529 496201670 25836495 55948321 25836495 55948321 25836495 55948321 55948321 55948321 55948321 80557941 55948321 55948321 55948321 80557941 55948321 80557941 55948321 80557941 55948321 55948321 25836495 25836495 25836495 55948321 55948321 80557941 55948321 55948321 55948321 80557941 55948321 55948321 55948321 80557941 55948321 55948321 55948321 55948321 49138326 55948321 55948321 80557941 80557941 80557941 80557941 121562851 121562851 121562851 80557941 121562851 80557941 80557941 80557941 80557941 55948321 80557941 80557941 121562851 121562851 212405591 212405591 265709955 212405591 212405591 212405591 265709955 265709955 265709955 265709955 311111802 265709955 265709955 265709955 265709955 212405591 212405591 212405591 212405591 121562851 121562851 121562851 121562851 1…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Middle So Far of the Wild signals - MEDIUM Coding Problem | CodeTikki