CT26376

Rhea's K-th Peak Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

At the alabaster quarry of Whitestone, Rhea records each registers in a worn leather ledger. The guild wants answers, not guesses. 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 <= 558; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 529 387 548961 -816319 781253 575122 812957 368267 -233322 -111310 -199030 363509 -350604 297092 -944779 -547401 -682142 -804963 745715 -640782 -372040 733452 -74088 -144504 -842813 -470773 -418997 334302 356205 396077 413871 -9409 184155 699237 208705 991868 308401 -900981 -357608 503599 -936116 119212 535685 -511130 -27504 65172 -648043 958474 -120116 -15405 -434184 -72268 493997 -689009 393136 -511309 961572 211582 -754879 -47046 63447 674297 -939635 874077 696492 883580 337067 -734943 93605 -22731 728592 -616910 -103139 -676371 -628594 -812315 259202 -498190 95718 -331723 -745315 390769 -796724 -512452 -700893 -817744 -316752 717312 366123 -498846 -565133 422224 -450085 380163 787939 -314358 924293 -749561 -576927 -446083 903158 -299583 -260481 629862 628451 -182012 447293 836774 -9132…
Output: -434184

Example 2:

Input: 190 138 -744283 -448071 -849796 583916 725214 -211359 822063 -566329 510069 -305745 2643 -964328 -716318 178275 227563 -439248 353096 63820 -397550 -694344 100744 441739 -87318 -557131 816209 -547728 -873835 -81636 -449251 510463 -36403 127392 -723270 493420 -448767 173178 -571185 -146475 -129048 655919 70525 -567772 -351284 885822 -592374 604857 96049 736605 368208 -120391 331842 -7830 -178241 -642374 543916 -198760 -790679 216508 100384 -906929 810254 -67222 -325254 -743662 31385 -355780 457361 -148493 -157937 971807 -359262 239525 829247 667611 -180854 290997 642984 222639 712379 -345721 -159300 816506 -309546 337206 -804432 385686 217892 -999213 12459 862667 -781281 570384 -470618 931966 -546791 735072 -319624 425103 -707745 -92317 305383 -241143 -237768 -663602 308551 -810714 -758519 …
Output: -470010

Example 3:

Input: 545 156 106235 -978807 241972 113210 -470467 269067 -203616 -618535 907670 71841 860790 582083 -446366 -414602 -65453 511160 -338746 -338410 78569 139678 -574403 -625029 -577346 71752 -558780 330526 -539112 -391109 593177 -93226 539762 -374646 -37065 550823 63093 153684 -738760 -300068 -582088 -459168 -495039 900951 -364561 -331681 -214768 135640 -885480 -295122 -620263 -667076 185955 531069 319845 309136 366126 -695411 -666085 -723380 -740561 -159674 100025 -606383 793725 -732486 -90629 -578220 -760606 -370578 358742 477487 109880 348061 605326 -266674 -230008 -45116 -752187 63789 765362 -689326 767329 -509127 496004 -579323 800920 631315 56434 -554703 195606 246718 634537 973344 -131129 285147 188665 -783242 -242486 934889 715027 -314961 554435 958871 85432 -619977 -775470 13140 109349 -…
Output: 406966

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rhea's K-th Peak Ledger - EASY Coding Problem | CodeTikki