CT24501

Tomas Counts the crates

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

At the savanna camp of Amberplain, Tomas records each crates 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 <= 640; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 354 155 230711803 960200641 942585736 249659501 554546499 582578481 135645601 669869421 79601034 127282893 479281492 441052514 510084462 479507270 168587149 514959220 307866848 790745397 374115119 904850614 841907246 986715377 380066272 789592410 89414736 924526408 814339298 662898648 599269428 801399577 492088914 30693193 355193846 223486425 472982926 65531053 377365763 166198443 496772545 770478169 318786315 645947993 996422105 858970267 459183457 837351383 258070259 259310430 671321106 961924082 265342166 480757168 380221852 940070185 736508989 958361344 605113486 328491547 637543837 826632854 10351045 846288981 762447469 399029953 866130307 445168535 808975087 739860992 502863918 846366879 264754282 480358108 41313781 375610558 775948028 99359751 42363987 963238311 87120102 69163989 37…
Output: 587960853

Example 2:

Input: 41 32 365789774 508899320 740131800 737744895 506976508 237804716 500156957 297523053 72512405 847502805 159401372 326814046 853094641 92338108 651390826 149662736 552986814 539562906 675678128 304314652 395899962 610462588 931249195 439584207 120779298 533362902 777742211 583271632 136168870 537498048 60653831 16545058 627285008 298447210 619309938 742319650 350426062 139703737 734573206 501241525 97832926
Output: 159401372

Example 3:

Input: 170 154 491621650 993403511 294897805 423898420 703067152 956940874 694585392 384556554 638715157 409719155 941063269 272611201 692636425 69444604 517744239 763448814 936340441 814408492 47393282 363923923 447202123 682992229 409951511 304377477 201325975 98278233 886569544 434778251 791124083 183806418 515057840 768459266 426547635 751032640 45533414 436803755 976006635 22192759 872182329 730333191 991511417 344929219 209487503 474205835 58614552 251792657 758897426 878388275 722421772 723645162 774948729 172872398 138139788 400303282 581201302 399250083 620865195 625199198 872081689 474554277 588690347 837308302 351107246 539426617 757063522 231632403 338834268 508089946 37040431 342599569 402705118 634590722 428537640 699690784 300207520 932517054 272238776 290164956 660493018 205002509…
Output: 172872398

Constraints:

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

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