CT21929

The K-th Peak at Scarlet Plain

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Before the gates of the poppy fields of Scarlet Plain close for winter, Yami must finish the weights ledger - one figure at a time. Task: Print the k-th largest element (1-based; duplicates count separately). Input format: First line: n and k. Second line: n integers. Output format: Print the k-th largest value. Constraints: 1 <= k <= n <= 350; -1000000000 <= a[i] <= 1000000.

Example 1:

Input: 327 72 -297784251 -359535509 -552490906 -46553708 -421681317 -245181518 -622070651 -864271843 -354047644 -632414390 -527459582 -271113900 -992047444 -153144293 -621946337 -79943455 -901616365 -556162253 -558040405 -518538145 -795223655 -376314071 -557720838 -531309058 -631011181 -38080959 -687622002 -668278500 -634874010 -836184341 -94892125 -179147405 -630572540 -455930095 -618361236 -268020751 -845600306 -305279231 -527010375 -241554767 -5058539 -953670256 -207747718 -544264730 -366611478 -304175001 -292420426 -407875393 -573480370 -495930830 -732716494 -934988449 -779408008 -303588745 -98960520 -811669330 -584655353 -792247018 -549433415 -705304717 -532898960 -951971715 -677237219 -255191090 -7765557 -876001613 -497237162 -831582234 -706030979 -586513584 -934671354 -756717378 -116532962…
Output: -255191090

Example 2:

Input: 245 14 -163957022 -917690297 -342537618 -608076920 -697580961 -339352286 -948744133 -806443005 -667714749 -20255490 -649155864 -68642763 -545845252 -737408640 -257209681 -229792376 -896709068 -760407633 -96759842 -528515067 -328641993 -516818499 -127972519 -9123264 -622883471 -7225879 -315969033 -441118569 -292063295 -127740351 -922956939 -79801796 -26000143 -701056028 -784447428 -550457272 -222253653 -902299845 -18215116 -258079128 -220087223 -876283418 -627890265 -302883018 -974292877 -671750313 -913990082 -655723585 -870332074 -904577924 -819392824 -733776982 -557952295 -297107590 -140672381 -210805102 -595864235 -234142461 -784506267 -748750250 -105094451 -703823260 -143573616 -866997609 -944270331 -510110291 -895233066 -844625183 -551623677 -159855876 -842190050 -721910683 -647215335 …
Output: -55849554

Example 3:

Input: 101 63 -674300804 -857408228 -915433055 -76614954 -222038967 -142294739 -591079416 -22009440 -877661538 -132039545 -511978614 -668966446 -842773542 -819507245 -639494130 -82207610 -313259203 -693617332 -850148559 -769241467 -315736422 -57315814 -142154641 -407229754 -623218316 -235574854 -263353357 -963973520 -213642769 -132916354 -878940542 -831122056 -62528843 -620992030 -246864748 -726723991 -970811418 -695929659 -218685024 -437015428 -324516688 -498457776 -650958285 -517680683 -521158383 -616362771 -303004193 -126082216 -761656927 -916866707 -202387006 -414139881 -704099481 -727957834 -762936729 -292015855 -288933076 -312682976 -839919000 -361549141 -428334936 -762197278 -449709137 -69333011 -903169405 -952979927 -314186461 -602663494 -653153229 -973419905 -987726720 -64578691 -8658929…
Output: -602663494

Constraints:

1 <= k <= n <= 350; -1000000000 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The K-th Peak at Scarlet Plain - EASY Coding Problem | CodeTikki