CT65109

The Middle So Far of Buzzwell

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the honey farms of Buzzwell. Hans spreads the ledgers records across the table and picks up a sharp pencil. 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: 1611 650331838 -34159284 743192373 -735939132 -479557014 -644460762 572951597 -215139994 212735555 -293487315 -505458676 587634981 475942984 -11751449 -195263918 -383902564 212692343 798802837 492856197 -72265245 -301387421 834134282 -788879240 -138857113 341902744 181298750 -887297556 -155194661 -76871992 194295336 220960627 -47171693 -52634756 -36675294 -812523768 -774450385 125229925 -441006652 -713102535 431655238 -211745118 -986462938 919792321 934285747 -612669546 45656476 -739902722 -299744991 -121124318 479995642 -292296039 -959564929 -874293346 678678936 274215799 364451710 -567702323 -35972897 -235926501 863506855 247476788 921820196 106337983 353800881 604018958 -877185712 -111651364 65889348 -496050666 131751745 112835451 -542410603 -105768196 -305536548 784038896 -248215183 -8…
Output: 650331838 -34159284 650331838 -34159284 -34159284 -479557014 -34159284 -215139994 -34159284 -215139994 -215139994 -215139994 -34159284 -34159284 -34159284 -195263918 -34159284 -34159284 -11751449 -34159284 -34159284 -34159284 -34159284 -72265245 -34159284 -34159284 -34159284 -72265245 -72265245 -72265245 -34159284 -47171693 -47171693 -47171693 -47171693 -52634756 -47171693 -52634756 -52634756 -52634756 -52634756 -72265245 -52634756 -52634756 -52634756 -52634756 -52634756 -72265245 -72265245 -72265245 -72265245 -76871992 -76871992 -76871992 -72265245 -72265245 -72265245 -72265245 -72265245 -72265245 -52634756 -52634756 -47171693 -47171693 -36675294 -47171693 -47171693 -47171693 -47171693 -47171693 -36675294 -47171693 -47171693 -52634756 -47171693 -52634756 -52634756 -52634756 -47171693 -526…

Example 2:

Input: 2413 -400434481 -724245496 415714637 -618429838 98020338 -643290780 936365286 874198484 645954124 695255456 306521187 400287075 757820674 -413604583 -996696311 402250168 -234951908 -489014669 977045440 833932728 488996752 198584835 -28565588 54553234 513283028 64045346 -720604103 -814572 -742467426 -241467500 675098947 -955047775 -575867927 530342097 -643852502 841661460 -610074754 -763578719 -992714603 -265014832 -418531758 908332943 -235417737 437645678 -368455495 -951058272 -888936774 -70258983 358595631 389267848 256230991 466839474 177036155 -269720455 933919137 -8507482 -328043577 -597523404 -602033848 -891234913 794174220 530550866 -397364497 -319125781 -954927294 459803039 -749382449 330999826 -14906950 939082728 -537787601 -601865488 277809964 -28754933 -374727187 -73039698 -33348…
Output: -400434481 -724245496 -400434481 -618429838 -400434481 -618429838 -400434481 -400434481 98020338 98020338 306521187 306521187 400287075 306521187 306521187 306521187 306521187 98020338 306521187 306521187 400287075 306521187 306521187 198584835 306521187 198584835 198584835 98020338 98020338 64045346 98020338 64045346 64045346 64045346 64045346 64045346 64045346 54553234 54553234 -814572 -814572 -814572 -814572 -814572 -814572 -28565588 -28565588 -70258983 -28565588 -28565588 -814572 -814572 54553234 -814572 54553234 -814572 -814572 -8507482 -8507482 -28565588 -8507482 -8507482 -8507482 -28565588 -28565588 -28565588 -28565588 -28565588 -14906950 -14906950 -14906950 -28565588 -14906950 -28565588 -28565588 -28754933 -28754933 -28754933 -28565588 -28754933 -28754933 -33348301 -28754933 -33348…

Example 3:

Input: 2651 -679922820 485248904 291662995 711833924 174256383 -624655004 359225791 -195007042 -767069156 -400222179 575521440 -499407596 554659471 -640387446 -296875880 -681414500 -795768210 -145259201 435337560 -966042197 322214589 -157569442 -973075903 -396144946 533906216 -533590628 -910227925 -4508318 22050225 895113138 859705767 907780038 182175671 -416593118 -357805473 646497475 -579125492 447200327 651615169 -10340077 -397491106 702181695 -610106903 -780396245 356448382 -143302818 109070451 -997424066 -56706106 148186061 -329549719 426196198 -631748769 -794940603 -144945210 -659748894 -537224672 -201673894 650562915 -769134679 -494051387 -639616603 -649823453 278008663 226281833 -953109052 -865651351 840116068 328280221 -939479420 -781250646 145626099 -491818818 389041572 518120290 -43946…
Output: -679922820 -679922820 291662995 291662995 291662995 174256383 291662995 174256383 174256383 -195007042 174256383 -195007042 174256383 -195007042 -195007042 -296875880 -296875880 -296875880 -195007042 -296875880 -195007042 -195007042 -195007042 -296875880 -195007042 -296875880 -296875880 -296875880 -195007042 -195007042 -157569442 -157569442 -145259201 -157569442 -157569442 -157569442 -157569442 -157569442 -145259201 -145259201 -145259201 -145259201 -145259201 -157569442 -145259201 -145259201 -143302818 -145259201 -143302818 -143302818 -143302818 -143302818 -143302818 -145259201 -144945210 -145259201 -145259201 -157569442 -145259201 -157569442 -157569442 -195007042 -195007042 -195007042 -157569442 -195007042 -195007042 -195007042 -157569442 -195007042 -195007042 -195007042 -195007042 -19500…

Constraints:

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

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