CT34922

Odin's Ledger of crates

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The archivist Odin has been asked to prepare the expedition manifest. On the desk lies a long table of crates readings. 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 <= 5331; 0 <= a[i] <= 1000000000.

Example 1:

Input: 1516 1097 433061359 753063602 2427019 134128676 879020634 224246242 988628923 891924969 696068002 19950412 781843578 806931073 74998520 190757617 71632912 579482692 350610124 202642111 311765007 227515866 528199554 952878785 430689972 139489101 861608254 662494895 618375784 887765081 697672556 124651265 849939985 23566950 430498254 53046606 944403937 891539771 591929418 136307201 61518974 595226662 763783803 905967618 795751575 962769682 90044493 263390946 80641777 560578325 399727233 142911965 83671030 820952404 416342339 275371247 12708874 256107060 646284032 887427523 362362862 154551756 493931444 740795860 343313311 6830193 250235947 843322181 265259162 69096680 381178506 882965235 718051133 70908754 666668369 675765491 407174713 29849360 828397345 34427895 543466105 837442248 13085552…
Output: 257323247

Example 2:

Input: 1786 865 851217569 351117839 393168985 950833775 159584979 113458986 553822892 120580006 470012404 736167720 758775579 642742558 913683731 631111233 307528851 444019178 323427638 536150461 293141432 790157645 986221953 175767427 349964268 514610741 825026779 209686821 568873369 449116533 446602636 527768547 149624451 253158445 411944312 635472065 464852338 495561583 110490271 537703975 14560274 43298129 354915929 431872400 733916610 479471360 92520145 282355748 177384773 212957789 121142592 538082717 193521785 979430884 565609136 323626476 271346337 53203868 293479026 883012573 131386042 880574970 558360362 394475998 494972501 692101634 691621716 891962628 716973493 764826516 498030771 87541070 567072918 823787762 748269087 957064752 822289349 91739200 285551412 409884928 301281329 4011111…
Output: 522687892

Example 3:

Input: 2396 1873 898854899 370841530 512199423 17054051 432607845 511177545 321542449 657466480 446226093 245248592 223129075 928246870 426912820 493228209 67382934 211916737 818342546 15847891 214868120 845902635 455878557 947034809 970707088 504538349 432325411 221057564 713929258 846739191 755579805 500672428 383074297 15045022 575054630 175355141 925455888 871253363 357679826 390335047 156819411 647745957 861585679 322335315 667757391 300114265 48304869 54733213 825306431 290844008 181401888 788750527 842710291 428665656 409366525 429983421 783592377 753035994 340030528 941949845 547967012 202883648 588224769 10200332 669579545 678894773 382839150 687190376 714032577 613523541 74120996 495125235 974366284 881806982 791926329 16458334 791279643 382727972 363858719 807238276 581197914 302555001…
Output: 227452114

Constraints:

1 <= k <= n <= 5331; 0 <= a[i] <= 1000000000.

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