CT59220

Esha Counts the marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the cinnabar mines of Vermilion pays by the answer, and Esha intends to earn it. First: the full register of marks. 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: 2894 -25896124 -817405453 959422114 639675295 364484890 -596989520 679877966 -95165892 -158710827 264736612 570270141 -216014243 668315606 -423151150 -197894092 -708558022 -419106331 70019630 -48285190 -316029250 696357856 511643785 -521005109 -438161911 691378496 -829810146 913732566 -338775701 889215532 347009506 -428678872 95224137 430695635 131294173 529035244 -533381841 -489474610 746530332 -693343185 797366971 -562935598 804041320 943154789 -404235452 -668485286 985299398 304377 655927839 -849988075 -764669083 -37955484 5090655 -334082281 -808743787 -834018666 722852836 133101763 936544723 545723337 212650624 -395726154 -665390364 73786589 -892765796 910557236 -257674387 121366155 345786681 -898585692 -391454108 35227169 -464683295 -889459938 563225220 -107619162 765048 846923429 538…
Output: -25896124 -817405453 -25896124 -25896124 364484890 -25896124 364484890 -25896124 -25896124 -25896124 264736612 -25896124 264736612 -25896124 -25896124 -95165892 -95165892 -95165892 -48285190 -95165892 -48285190 -48285190 -48285190 -95165892 -48285190 -95165892 -48285190 -95165892 -48285190 -48285190 -48285190 -48285190 -25896124 -25896124 70019630 -25896124 -25896124 -25896124 -25896124 -25896124 -25896124 -25896124 70019630 -25896124 -25896124 -25896124 304377 304377 304377 -25896124 -25896124 -25896124 -25896124 -37955484 -37955484 -37955484 -25896124 -25896124 304377 304377 304377 -25896124 304377 -25896124 304377 -25896124 304377 304377 304377 -25896124 304377 -25896124 -25896124 -25896124 -25896124 -25896124 304377 304377 765048 304377 765048 304377 765048 765048 765048 304377 765048 …

Example 2:

Input: 2527 -413753517 -822681736 231758875 430881630 -753016483 446849327 351202691 -708130391 -516116052 582637494 -288442968 985457527 -598658824 -994400593 105672525 91049002 337648704 82938926 -387222844 -760986297 -217336584 679336575 -126825063 988811190 -374324337 353715487 -122869338 -701422265 -108790805 232433876 747859893 -629582036 11794878 264058560 -53543353 909358080 211864831 332784349 -416270130 -409880510 338189477 -558148418 -129223969 51017917 -23097963 -159346689 -622211095 -720677414 -18371445 550183440 454863414 -976499063 939180381 856990134 -373367878 91169759 2111413 -678104374 107829748 168661244 -952675524 697375359 890871614 344377602 275288472 -916581504 -62018386 -562075444 -947204330 -641057003 93218066 280298792 -810746591 -613439459 716564944 -350275507 68817475…
Output: -413753517 -822681736 -413753517 -413753517 -413753517 -413753517 231758875 -413753517 -413753517 -413753517 -288442968 -288442968 -288442968 -413753517 -288442968 -288442968 91049002 82938926 82938926 -288442968 -217336584 -217336584 -126825063 -126825063 -126825063 -126825063 -122869338 -126825063 -122869338 -122869338 -108790805 -122869338 -108790805 -108790805 -53543353 -53543353 11794878 11794878 11794878 -53543353 11794878 -53543353 -53543353 -53543353 -23097963 -53543353 -53543353 -108790805 -53543353 -53543353 -23097963 -53543353 -23097963 -23097963 -23097963 -23097963 -18371445 -23097963 -18371445 -18371445 -18371445 -18371445 2111413 2111413 11794878 2111413 2111413 -18371445 -18371445 -23097963 -18371445 -18371445 -18371445 -23097963 -18371445 -23097963 -18371445 -18371445 21114…

Example 3:

Input: 1537 -92110839 788789799 -203615560 972035754 -387298187 -179944608 -905470639 -696341507 -638337510 -843191446 347299679 -565842704 -325695838 -967661672 643678742 579253037 606429141 371358655 -924533040 -27108186 -418756753 -398270848 53520485 -970432538 -874962592 -294774872 52042260 731146711 752362322 -116623475 -625538315 631676446 -831630100 -782844895 396947009 -470673381 425801741 388367116 -550935394 -784413288 830175323 -325732656 558726467 904431296 619811353 -805421386 379680795 589726703 -507367551 838008554 -646565825 152252855 923796547 -787121427 173746634 28829416 -736330607 127777509 355778717 340054962 323108503 -960072391 340434915 -826807151 92362144 -68944520 513134310 820074682 918444622 -713139343 867869892 993757582 379665250 -126756640 490059015 -870657669 -2777…
Output: -92110839 -92110839 -92110839 -92110839 -92110839 -179944608 -179944608 -203615560 -203615560 -387298187 -203615560 -387298187 -325695838 -387298187 -325695838 -325695838 -203615560 -203615560 -203615560 -203615560 -203615560 -325695838 -203615560 -325695838 -325695838 -325695838 -294774872 -294774872 -203615560 -203615560 -203615560 -203615560 -203615560 -294774872 -203615560 -294774872 -203615560 -203615560 -203615560 -294774872 -203615560 -294774872 -203615560 -203615560 -179944608 -203615560 -179944608 -179944608 -179944608 -179944608 -179944608 -179944608 -116623475 -179944608 -116623475 -116623475 -116623475 -116623475 -92110839 -92110839 -27108186 -92110839 -27108186 -92110839 -27108186 -68944520 -27108186 -27108186 28829416 -27108186 28829416 28829416 52042260 28829416 52042260 288…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Esha Counts the marks - MEDIUM Coding Problem | CodeTikki