CT46153

Rowena's Lunar Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Rowena runs the workshop at the lantern district of Glowfen. Today the books show a list of registers, and the numbers must be worked out before sundown. 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: 1261 129 -32834390 152461287 111206585 -988014734 -441959322 178442210 -886942436 740980999 202635108 807296564 -729330895 -427724713 -454442103 -480453414 349000311 276051805 -982686493 511774301 -303339344 588998727 168553159 -581266722 633953293 806474942 -278243584 124548744 -140056990 819029659 133114095 -928154431 -7886798 49543285 527632285 -166756103 -37298253 374144275 -911748991 458660242 -715473465 892258824 -187139279 -935619361 -688270329 875894885 694838571 -496266653 292772424 991655544 16262498 -881721984 428422651 415670011 767000214 -644874209 -298055127 -605527415 -767355091 867133810 -629619173 -250847193 -695225226 84052085 -443931749 34354036 -844420490 123567817 267808902 -192685980 302954106 813649597 804245938 203085611 212979732 -622215098 645205590 22232152 29212…
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 -988014734 -982686493 -949661565 -935619361 -928154431 -911748991 -911537446 -910231507 -886942436 -881721984 -870531402 -855142026 -844420490 -792272835 -767355091 -763781375 -753170296 -732001069 -729330895 -717929982 -715473465 -695225226 -688270329 -682971133 -668527268 -663339385 -644874209 -636932925 -629619173 -629619173 -622215098 -622215098 -605527415 -605527415 -596192658 -582765049 -581266722 -56051838…

Example 2:

Input: 134 42 125946590 -146685304 -785553207 -134002633 -781706455 -925208620 -596258754 545938468 -924895669 -264498470 -225183093 -887957674 563511111 -639671416 432699162 -626893558 469042690 979143875 -60176006 809955620 390754437 -329221842 324698740 842071337 -703146200 891952544 -129287720 776802255 643211874 -578178544 -71351949 769784090 876242639 -406837665 56684323 581057405 -769144996 4145635 -542972670 -237152503 -454727603 -766532246 -231743265 -51775609 -389687966 -595888261 950557358 -707195259 313259816 60630243 654836437 544839532 962599827 519862416 78622881 2795344 273302637 381810534 -192773747 -477233112 68639129 -646620308 146765048 -955592977 -62641368 -745797270 102650813 778286106 -853418267 159392696 -766072164 -885763732 440996839 946722254 145155821 312150181 2941987…
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 -925208620 -924895669 -887957674 -785553207 -781706455 -769144996 -766532246 -707195259 -703146200 -639671416 -626893558 -596258754 -595888261 -578178544 -542972670 -454727603 -406837665 -389687966 -389687966 -329221842 -329221842 -264498470 -264498470 -237152503 -237152503 -231743265 -225183093 -225183093 -192773747 -192773747 -192773747 -146685304 -134002633 -129287720 -71351949 -62641368 -60176006 -60176006 -51775609 2795344 4145635 4145635 56684323 60630243 60630243 68639129 68639129 78622881 78622881 78622881 78622881 102650813 102650813 102650813 102650813 102650813 125946590 145155821 146765048 159392696 273302637 273302637 294198753 294198753 312150181 31215018…

Example 3:

Input: 809 762 -370736981 -162280987 463299417 300801160 10040906 -478635802 208486732 519859909 -503442927 -569831398 -725881518 837106840 157422990 -687523042 442898805 -703147491 -342785007 2502590 -601574609 -858008537 577267294 -98200929 113566611 215683307 -37521803 970058727 662333150 457872699 824684649 -797257369 -861104051 -527548859 -480492011 214420538 -276902128 637371529 500853277 35210049 -143788464 887642360 559375277 215739517 473522862 -75198069 -371190228 776760434 386346563 -661808760 435994772 606219860 -41763388 -997384323 -574345514 -398340518 -591872635 -548690195 533833588 -848889137 797978000 -974729947 259465874 -330440511 -690600364 22520079 362073255 -337744117 -302948424 223649279 247315240 -485992906 116901940 -283678782 -228030420 -159032288 -643219909 -867838283 7…
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…

Constraints:

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

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