CT45843

Lata's Radiant registers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the marble forum of Argentium; Lata weighs the day's registers manifests and starts the calculations. 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: 3340 371 -238998057 502680130 -954596460 -147386503 59726454 -850737008 459337148 944164072 764643588 264687218 748706021 -825828813 235133009 407415960 -649519041 361078405 -283158806 -252727627 -87451752 -140456122 -542230281 -529064577 -259019146 -877300093 612075511 950959768 -361696043 -508006658 -663615780 151230456 249944370 -227166108 -58410162 -336770018 907076172 508422023 541068745 723904621 901715096 87284872 515961661 -999999569 -892074142 -176443595 -650000893 -861248170 872923334 233876488 -183180914 471703606 -845138159 263901767 -109581719 980856271 -689497952 -818845180 601175479 726713602 -285084653 92473960 630826878 -918700608 331716310 679667971 27260494 -314092736 -763623128 499147389 995758930 851832994 -758122679 365223894 -231922038 384818848 193546498 744267326 8…
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 2:

Input: 185 24 -825500609 115247725 103548628 573554661 409319018 -308876278 -107965530 301443408 737527142 -241948613 34314625 842794695 430792462 -375866252 -805593122 -865371117 145299343 714338424 925716544 272233352 266324196 722194596 725603787 363479506 140481652 243158533 12482052 -104568 683027685 -143141717 461540322 571036348 737963951 -149679284 -863538135 -987307108 952293683 -104723697 -172092562 48898090 905512549 648197056 -934273236 630086105 -534073315 -571698655 -556823740 -480471352 866634573 -851219631 -123860128 -446221995 -415164011 -684558840 436887934 -755613310 -977578273 -408762846 226120012 -592852472 266052504 80527914 740524212 -446916262 863801163 -594727310 374938613 294139911 346115921 690328601 882855773 -699812239 -953485955 -988494143 263475379 52110210 19528182…
Output: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -865371117 -825500609 -805593122 -375866252 -308876278 -241948613 -143141717 -107965530 -104568 12482052 12482052 12482052 12482052 34314625 34314625 34314625 48898090 103548628 115247725 115247725 140481652 140481652 140481652 140481652 140481652 145299343 145299343 145299343 145299343 145299343 145299343 243158533 243158533 243158533 243158533 243158533 243158533 266052504 266052504 266324196 266324196 272233352 272233352 301443408 301443408 346115921 363479506 374938613 374938613 374938613 374938613 374938613 374938613 374938613 374938613 374938613 374938613 374938613 374938613 374938613 374938613 409319018 409319018 409319018 430792462 430792462 430792462 430792462 430792462 430792462 430792462 430792462 430792462 436…

Example 3:

Input: 3774 52 658871778 545029931 424625347 -839365660 -763579522 739078941 -256102498 963953756 -778257625 -949581734 -225370561 946706825 -646883175 -677604164 -506199324 -30948485 197112611 359695463 800373175 641937183 855279031 102892844 320227510 255713019 564216852 144671773 -717301440 -111447987 372397214 629201085 -597434481 570200192 -72706575 -506768815 -879007229 67153852 635831297 -944538186 593821889 -215348005 -778723742 87910481 336973161 -800135316 630789571 -896430426 -944317881 312014842 -160989456 13889722 -113829236 -37761001 342294821 -451477463 771744953 -840084089 -11172737 487931281 333881159 951570491 -481827976 -418361637 60875808 652900820 -658192266 266136969 303070632 335036849 -550886740 -131282508 -238827289 874208998 -828644295 -277263527 541191076 -857133497 558…
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 -949581734 -944538186 -944317881 -896430426 -879007229 -840084089 -839365660 -800135316 -778723742 -778257625 -763579522 -717301440 -677604164 -658192266 -646883175 -597434481 -506768815 -506768815 -506199324 -481827976 -451477463 -451477463 -418361637 -277263527 -277263527 -256102498 -256102498 -256102498 -238827289 -225370561 -215348005 -160989456 -160989456 -147658741 -147658741 -147658741 -147658741 -147658741 -131282508 -113829236 -111447987 -72706575 -37761001 -37761001 -37761001 -37761001 -37761001 -30948485 -30948485 -11172737 13889722 13889722 60875808 60875808 60875808 67153852 67153852 67153852 67153852 87910481 102892844 102892…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Lata's Radiant registers - MEDIUM Coding Problem | CodeTikki