CT23590

The ledgers K-th Peak Puzzle

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the shipyard of Keelwind, someone must plan the festival budget. This year the task falls to Tina, armed only with the ledgers register. 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 <= 697; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 7 7 282480446 218068070 719465076 986525281 782215450 296458627 996328784
Output: 218068070

Example 2:

Input: 526 231 791487377 934180890 983765272 941722156 782987213 837890037 394386660 512369830 807054720 372347833 765664273 640970105 233252510 15014722 882354323 759953647 206351269 735090817 775223305 242178244 569483858 573353910 140449929 564718306 312974800 382524100 825420123 872969641 545434151 600219031 205486988 987131097 984991730 339236444 273745326 781271639 852111432 205599471 443252404 699774562 834635135 612502188 260725336 938607195 519014761 672167857 411348155 354597721 47980332 514605602 932619371 615068506 163290927 894379753 59247367 300114184 278954190 831025233 36908396 267707399 678017356 889957646 83304446 567410565 264231092 118775920 238320090 899895467 832660310 625279011 846136455 652347189 584498651 39201720 781843766 669585410 110735688 175086776 830048193 59001051…
Output: 572501133

Example 3:

Input: 70 32 166720389 487025813 700657656 487993337 821325670 63901966 667517964 894627380 982588965 962904819 838696492 589127466 719402402 308300887 104929929 232069743 733418033 241464508 239060818 500669545 324132716 324886119 510573002 899226469 240925292 427760328 848987165 261933528 115984102 166531755 387607520 157235365 334877591 466972028 471681773 624390606 565646138 91277036 238084222 395673355 962901014 214416225 242624573 830258427 496642735 714470188 649062142 998685876 318409063 522794590 367196810 882256804 860199932 300167538 438764609 38445661 762592302 156237764 520480256 77368752 738148715 127626715 991480115 494649239 957186413 138979341 921194746 444624067 296242058 726490065
Output: 496642735

Constraints:

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

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