CT60158

Smoky registers Middle So Far

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the snowberry thicket of Winterholt, Librarian studies rows of registers entries. One clean number will settle the guild's oldest argument. 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: 990 300532749 -895757406 -693097744 -609428600 -212745505 -15491681 -6360520 -949119017 972434229 429061322 942059452 -743958552 -79346431 633290963 629466437 -10398653 -973417212 823453079 -871793517 -300396206 947835834 -707481205 -117283378 363376481 -843480106 -214416564 850894453 -881577222 -152529543 -971038166 303754922 -362825004 -195131323 782748900 786743499 853136914 855130659 233247324 -752134376 969421923 455514040 661252663 338051101 -558797288 -630830138 758665977 616678466 606284344 149492904 -795086561 764654236 567971358 -529472708 -992068633 -812507987 748770578 342469386 535469912 664590882 -716918758 165037821 -916846697 894071881 187653045 -318552240 144533889 -496058788 -910491969 -592967726 105604485 243097030 -371629488 -315241884 -661095522 -352458983 484956939 40…
Output: 300532749 -895757406 -693097744 -693097744 -609428600 -609428600 -212745505 -609428600 -212745505 -212745505 -15491681 -212745505 -79346431 -79346431 -15491681 -15491681 -15491681 -15491681 -15491681 -79346431 -15491681 -79346431 -79346431 -79346431 -79346431 -117283378 -79346431 -117283378 -117283378 -152529543 -117283378 -152529543 -152529543 -152529543 -117283378 -117283378 -79346431 -79346431 -79346431 -79346431 -15491681 -15491681 -10398653 -15491681 -15491681 -15491681 -10398653 -10398653 -6360520 -10398653 -6360520 -6360520 -6360520 -10398653 -10398653 -10398653 -6360520 -6360520 149492904 -6360520 149492904 -6360520 149492904 149492904 149492904 144533889 144533889 -6360520 -6360520 -6360520 105604485 -6360520 -6360520 -10398653 -10398653 -10398653 -6360520 -10398653 -10398653 -103…

Example 2:

Input: 1331 826214599 -539005411 -700028980 993459609 -365307441 -120860735 -859353612 925905017 -251189255 -289048649 92367859 -599201735 456113638 -607318928 -640411817 473147856 930574417 -985363070 448682835 535023730 133622751 -173894846 132594993 -875131154 194927152 591879566 -755223325 -850750642 -787462295 632636430 932397105 770200436 -200199574 -26053940 -382695610 -867159399 513716959 -821563692 217304544 908295920 287902942 781696691 -505639033 -425480385 -838733326 -856930465 -113406689 26417838 -47728278 560469756 -806165334 312538000 602571973 -677593579 -844366711 979976213 277422831 100769752 710982790 486153989 793504535 -133729320 -231184157 488037004 662625461 784173725 -121656872 -31547754 -484125262 848502937 414012174 -410364957 -724497710 30012100 205936654 65638519 -1713…
Output: 826214599 -539005411 -539005411 -539005411 -365307441 -365307441 -365307441 -365307441 -251189255 -289048649 -251189255 -289048649 -251189255 -289048649 -289048649 -289048649 -251189255 -289048649 -251189255 -251189255 -120860735 -173894846 -120860735 -173894846 -120860735 -120860735 -120860735 -173894846 -173894846 -173894846 -120860735 -120860735 -120860735 -120860735 -120860735 -173894846 -120860735 -173894846 -120860735 -120860735 -26053940 -26053940 -26053940 -120860735 -120860735 -173894846 -120860735 -120860735 -113406689 -113406689 -113406689 -113406689 -47728278 -113406689 -113406689 -113406689 -47728278 -47728278 -26053940 -26053940 26417838 -26053940 -26053940 -26053940 26417838 26417838 26417838 -26053940 -26053940 -26053940 26417838 -26053940 -26053940 -26053940 26417838 26417…

Example 3:

Input: 2295 214451577 667849139 -218641250 -181874363 798949620 766802247 698601403 435715632 -785412622 -196963516 -82598024 945665120 233874228 -834791441 -434940751 22507419 964701107 -695895242 -842871081 12901162 877920786 -403381994 28595764 414722682 433900156 -541212571 185596382 478326149 -199268418 -5432831 -143707355 -913706863 -156544497 -217671075 -59066659 341905094 516960724 706663410 13483945 513793189 -918209193 -549335777 -52668797 839389072 -521395538 362151247 430947733 458555954 -243833839 -452941496 541831111 765146475 -951277589 -77093183 -121859779 401330130 -795699222 289677081 -470585019 -586545740 776709214 -714233115 -917051371 -779628092 -421923575 -256718518 -141626719 635980576 -272514477 -780455974 -440950405 517098485 -364204514 69370647 -141412824 -666745583 7844…
Output: 214451577 214451577 214451577 -181874363 214451577 214451577 667849139 435715632 435715632 214451577 214451577 214451577 233874228 214451577 214451577 22507419 214451577 22507419 22507419 12901162 22507419 12901162 22507419 22507419 28595764 22507419 28595764 28595764 28595764 22507419 22507419 12901162 12901162 -5432831 -5432831 -5432831 12901162 12901162 13483945 13483945 13483945 12901162 12901162 12901162 12901162 12901162 13483945 13483945 13483945 12901162 13483945 13483945 13483945 12901162 12901162 12901162 12901162 12901162 12901162 -5432831 12901162 -5432831 -5432831 -52668797 -52668797 -59066659 -59066659 -59066659 -59066659 -77093183 -77093183 -77093183 -77093183 -77093183 -77093183 -82598024 -77093183 -82598024 -77093183 -82598024 -77093183 -77093183 -59066659 -77093183 -59066…

Constraints:

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

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