CT61895

Nora's Northern Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Nora the paymaster watches over the fjord village of Deepwater's stores of ledgers. A careful computation stands between order and chaos. 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: 2241 647777067 634517846 -712406127 711792565 -816647344 929800964 -76748398 -281004940 -102011863 -55899861 -480767777 -60349256 -382910273 660841861 532362013 497937749 -921161302 657029411 -790153679 830007094 20957330 -233414671 -618854271 207378211 -764445486 -909504658 -934937300 -352841903 -41751868 49684824 -308329228 -484619981 85090191 -31288791 -445798556 111017495 -167095213 -95302386 415674664 -944070330 -63982443 271852898 347161002 -124208436 -263055720 845420777 898377443 665786939 -177528989 120150738 99592123 811693102 616808400 -555143434 -489060309 126324472 -877519996 -541929147 721682099 -252868723 39050252 224230881 -604588962 -1824769 879872208 -460197418 -468300280 945905999 -142173913 -528168973 243202428 -781161664 -946635815 -319904409 946921075 -262390437 64284…
Output: 647777067 634517846 634517846 634517846 634517846 634517846 634517846 -76748398 -76748398 -76748398 -76748398 -76748398 -76748398 -76748398 -60349256 -60349256 -60349256 -60349256 -60349256 -60349256 -55899861 -60349256 -60349256 -60349256 -60349256 -76748398 -76748398 -102011863 -76748398 -76748398 -76748398 -102011863 -76748398 -76748398 -76748398 -76748398 -76748398 -95302386 -76748398 -95302386 -76748398 -76748398 -63982443 -76748398 -76748398 -76748398 -63982443 -63982443 -63982443 -63982443 -60349256 -60349256 -55899861 -60349256 -60349256 -60349256 -60349256 -63982443 -60349256 -63982443 -60349256 -60349256 -60349256 -60349256 -55899861 -60349256 -60349256 -60349256 -60349256 -63982443 -60349256 -63982443 -63982443 -76748398 -63982443 -76748398 -63982443 -76748398 -76748398 -9530238…

Example 2:

Input: 1731 -492696553 175205654 -538197419 829116492 778136953 254220588 573213619 610001522 -978327399 601970543 350398086 -660408202 -890872620 448841783 4023258 360061817 -982975405 716439369 784282651 -820164920 -861418738 890002580 841255823 -975531974 902008223 170615090 644094323 322291370 -194925682 896904581 38156355 771800426 -636126776 129323383 824613794 -136347223 594647548 750050066 12197254 950365912 -173545228 -771728508 -352014227 344557228 33917840 -826518476 68665980 277900957 -816226585 111235748 737074801 558979249 -722574875 -150764695 -11203590 717103262 -786577056 461909431 780548304 -834860455 707315551 -259499529 44580543 438829678 751608377 -226758190 -881567607 132674207 -26457185 -473446106 -813175742 -752877954 425117627 204975016 689256606 -792277118 -212682045 -13…
Output: -492696553 -492696553 -492696553 -492696553 175205654 175205654 254220588 254220588 254220588 254220588 350398086 254220588 254220588 254220588 254220588 254220588 254220588 254220588 350398086 254220588 254220588 254220588 350398086 254220588 350398086 254220588 350398086 322291370 322291370 322291370 322291370 322291370 322291370 254220588 322291370 254220588 322291370 322291370 322291370 322291370 322291370 254220588 254220588 254220588 254220588 175205654 175205654 175205654 175205654 170615090 175205654 175205654 175205654 170615090 170615090 170615090 170615090 170615090 175205654 170615090 175205654 170615090 170615090 170615090 175205654 170615090 170615090 132674207 132674207 129323383 129323383 111235748 129323383 129323383 132674207 129323383 129323383 111235748 111235748 111235…

Example 3:

Input: 851 238554980 -528530722 956715222 242351985 288584944 -875636176 -396116880 150316138 354555661 -607363469 351614481 -556497478 830476780 618158385 -795425131 -459130879 -973612524 -853584152 -688987559 -310039319 674167566 -128108486 591547881 -6573078 956572166 426560558 -333291100 316701852 284175328 -350418942 -435700297 -484703211 605537494 -458536779 -893607216 68380080 -554985116 -837919306 525857636 -233830339 -892907861 880510113 900761379 719485366 452785163 -759103661 -539126154 578538112 -894646771 -824175272 339883880 -756400872 -418323927 608410372 893013598 -768862178 -763855411 -173244187 900160431 826937926 875335737 681933030 326102997 -580997716 -248933645 256759130 -201414022 779730581 765191250 -922835686 606826365 -92631234 -578068195 239346756 -823293442 409633592 -…
Output: 238554980 -528530722 238554980 238554980 242351985 238554980 238554980 150316138 238554980 150316138 238554980 150316138 238554980 238554980 238554980 150316138 150316138 -396116880 -396116880 -396116880 -310039319 -310039319 -128108486 -128108486 -6573078 -6573078 -6573078 -6573078 150316138 -6573078 -6573078 -128108486 -6573078 -128108486 -128108486 -128108486 -128108486 -310039319 -128108486 -233830339 -233830339 -233830339 -128108486 -128108486 -6573078 -128108486 -128108486 -128108486 -128108486 -233830339 -128108486 -233830339 -233830339 -233830339 -128108486 -233830339 -233830339 -233830339 -173244187 -173244187 -128108486 -128108486 -6573078 -128108486 -128108486 -128108486 -128108486 -128108486 -6573078 -128108486 -6573078 -92631234 -92631234 -92631234 -92631234 -92631234 -9263123…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nora's Northern Ledger - MEDIUM Coding Problem | CodeTikki