CT38685

Last registers of Esha

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the basalt cliffs of Obsidian Shore close for winter, Esha must finish the registers ledger - one figure at a time. 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: 129 54 216543409 -767409887 -474928901 951143652 747135404 -936469343 139979360 -732570569 -437537079 392257390 -100839859 -27602710 -308731853 -265777842 -297276010 755586565 30287006 -841957155 -879505906 430284889 244798780 -762664467 -58213514 -470741778 -858154462 301208979 -885975387 -285861677 -451832201 72652853 -930022478 334099832 -42938346 -703581917 296702710 445235618 841795216 251556895 228207165 22221735 96287813 -864305890 955211501 -542804272 718488349 541270374 -878228391 392552212 -65650356 -137641749 -486132415 -214379627 -246113778 -18295074 -479788954 814572407 -305244107 -751748710 -323269351 -961891825 784935482 -672716527 10533242 -901358301 370322273 -276493649 -50185841 -819614925 -911455062 727555723 -372836866 574662492 620098794 -728712469 3623364 -721821503 -…
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 -936469343 -930022478 -885975387 -879505906 -878228391 -864305890 -864305890 -858154462 -841957155 -767409887 -767409887 -762664467 -751748710 -732570569 -732570569 -732570569 -703581917 -672716527 -542804272 -486132415 -486132415 -479788954 -479788954 -479788954 -474928901 -470741778 -451832201 -437537079 -372836866 -323269351 -308731853 -305244107 -297276010 -285861677 -285861677 -276493649 -265777842 -265777842 -265777842 -265777842 -265777842 -246113778 -228100060 -222799532 -222799532 -222799532 -214379627 -214379627 -214379627 -166708300 -137641749 -137641749 -116768710 -100839859 -100839859 -65650356 -58213514 -50185841 -42938…

Example 2:

Input: 2443 727 842000116 -396241349 479157041 -406752936 -224396758 776709311 22605687 -42245469 -694661131 -310489181 -780571865 -907591989 -793560316 -407340279 -359481462 114451663 -526311765 30141683 -408873868 65562273 457437152 -764739023 977079750 40974182 -581811465 425032207 558040653 300141113 640992241 -249790368 444777108 -729631632 477243897 452709861 616543489 685078481 -954135175 -709148999 -727336832 206697565 968795662 -880373718 -742493623 -217212359 -211217252 -841345346 -265688079 -690906726 -706651344 -927508101 393441846 -507439316 341470180 -93015458 533091129 827996643 366674549 -678836060 797980028 849876321 871879246 -708315792 -6217017 -143352864 97846999 -682171818 667197319 855432175 -19170731 336497373 920581063 -642555534 417213139 609878724 -162168200 909642916 55…
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: 56 5 688006 -234707755 296036350 889331056 -917289956 -890448851 -665171722 -445473531 42097697 244076953 940231373 -193033061 -82693546 -237712706 86116290 -786142711 -490472527 -488201684 -526949462 -432042635 327780668 -18536921 -968332717 66103268 681984596 473004804 348944031 -528262795 -380179887 -957371298 -760113339 154884299 242476978 -525182193 950169084 -802481300 -430754584 -757008938 865471186 -694858781 367040680 813760682 -651633640 476430052 227792097 -304826058 342054026 -734940641 302061834 368644192 939454652 -664972134 -482463410 -87754949 -339098519 434303392
Output: -1 -1 -1 -1 -917289956 -890448851 -665171722 -445473531 -234707755 688006 42097697 42097697 42097697 42097697 86116290 86116290 86116290 86116290 86116290 86116290 244076953 244076953 244076953 244076953 296036350 327780668 348944031 348944031 348944031 348944031 348944031 348944031 348944031 348944031 473004804 473004804 473004804 473004804 681984596 681984596 681984596 813760682 813760682 813760682 813760682 813760682 813760682 813760682 813760682 813760682 865471186 865471186 865471186 865471186 865471186 865471186

Constraints:

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

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