CT53427

The K-th So Far of Whitesnow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Dev found an old ledger of marks in the archive attic at the tundra station of Whitesnow. The margin notes pose a precise question. Task: As values arrive one by one, after each arrival print the k-th largest seen so far, or -1 while fewer than k values exist. Input format: First line: n and k. Second line: n integers. Output format: Print n answers space-separated. Constraints: 1 <= k <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 90 13 -643226694 830680695 861988725 -41158274 -888440173 453466898 -247324262 -849305350 629429658 -551072328 972673461 -224142946 -492545012 -403635359 554562325 666176086 -805373222 -402439043 -657913675 -436699016 147632091 -535866969 465469818 300014826 -625754111 -838733063 585000688 828821386 -916509814 576517353 113912543 649222712 247556156 -822212050 507296893 -559720348 -643292001 905611367 707577473 -944844222 316910204 -449909890 519545208 -899401425 -823297096 933031880 -214014440 -327421834 961937035 693964602 724607263 472397392 -519171647 -617204512 -881032010 359287612 -330351822 894578272 -854572840 -827165415 629584559 -456086796 903867921 730424750 -430638195 946059844 -732650801 -800734216 241915343 -698870960 180860725 290509428 -235745565 313145069 -640166091 303749…
Output: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -888440173 -849305350 -643226694 -551072328 -551072328 -492545012 -492545012 -436699016 -403635359 -403635359 -402439043 -247324262 -247324262 -247324262 -224142946 -41158274 -41158274 147632091 147632091 300014826 300014826 300014826 453466898 453466898 453466898 465469818 507296893 507296893 507296893 507296893 519545208 519545208 519545208 554562325 554562325 554562325 576517353 585000688 629429658 629429658 629429658 629429658 629429658 629429658 629429658 649222712 649222712 649222712 649222712 649222712 666176086 693964602 693964602 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 707577473 724607263 724607263 724607263 724607263 724607263 724607263 724607263…

Example 2:

Input: 1226 1027 -27857657 282235770 540739881 695212722 739558649 736592080 -908502490 -303399632 716091638 -933572566 -214777231 -24451690 -884187649 -649665388 -620133783 -991674863 630728856 202200519 279317115 -290226051 559107529 -307737082 -568272834 968355065 949913799 910200913 595376095 -855318131 -395451228 -393884751 -520368688 -752868720 -955637055 604235474 487976233 966547173 435373660 955519217 -364218522 -855640237 607426140 693294695 184631096 -879142830 -125270178 870065058 381348188 -567806918 815770107 306732979 -787575667 544076754 730927775 524898072 373574917 -701869560 557646049 434626744 260380788 -426540039 -847782770 722189591 -176125076 211063542 966204974 -660218601 -852357221 758722000 499886823 928789350 399245150 -796318734 303910382 213824737 220586280 -796072153…
Output: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1…

Example 3:

Input: 2581 10 38952941 981284017 -864916251 240998893 -835067138 370711742 -485343505 561678005 390749209 -823801866 -174323292 139857254 -156451610 -836362652 -612222706 272704382 529078762 488918583 352280117 446724358 975357499 -692396551 506606564 550781826 -261244389 257217969 -371138529 909159745 -937829858 -493281163 -124039637 -295426560 778446521 398197487 -23058782 325077536 873565394 323017307 292751999 469187203 -144593690 661509714 -728272902 27565330 76991103 802617216 616981123 454249817 439172759 -703987656 704882551 488933503 678244195 -176672009 553493602 -531314448 509773074 -985452214 -200340519 -717819140 -188913243 -431810290 -608814541 -828434816 -605582712 -531510867 -362115801 -663200526 313209912 398308331 -120552073 -99700642 -860144409 -838350531 -812904647 242085575 …
Output: -1 -1 -1 -1 -1 -1 -1 -1 -1 -864916251 -835067138 -823801866 -485343505 -485343505 -485343505 -174323292 -156451610 38952941 139857254 240998893 272704382 272704382 352280117 370711742 370711742 370711742 370711742 390749209 390749209 390749209 390749209 390749209 446724358 446724358 446724358 446724358 488918583 488918583 488918583 488918583 488918583 506606564 506606564 506606564 506606564 529078762 550781826 550781826 550781826 550781826 561678005 561678005 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 616981123 619776459 619776459 619776459 619776459 619776…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The K-th So Far of Whitesnow - MEDIUM Coding Problem | CodeTikki