CT33214

Envoy's registers K-th Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the mountain city of Highreach, Envoy studies rows of registers entries. One clean number will settle the guild's oldest argument. 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 <= 5779; 0 <= a[i] <= 1000000.

Example 1:

Input: 315 53 677798 863348 973621 995087 960687 870737 279449 88983 684527 990458 469102 982188 274802 450467 342646 141447 688623 738955 226367 956817 376533 620524 460679 713586 236807 874909 992257 987987 350186 903261 285001 979724 738032 336399 504959 699461 917385 225912 239408 489359 792379 450968 231828 715345 373869 384282 871824 879324 947145 785382 70791 602362 104123 367204 12663 65650 727556 496705 182954 553853 505383 458533 258078 243943 565021 248334 899176 428746 969153 275848 914790 942064 484752 362995 761742 402174 224319 643076 519734 499859 408827 627009 890873 515099 575467 962612 751128 944921 808974 580569 555594 210631 84170 718840 167653 40131 880946 78789 434174 729616 144841 505029 826653 142719 346239 539182 334509 377112 774317 465100 256859 951071 580251 130188 91…
Output: 863348

Example 2:

Input: 3723 302 636060 854550 631317 842431 517786 134353 855581 943090 288302 636818 226240 355682 834477 512948 295 285302 778056 703577 174725 397692 680444 301963 161833 173217 836388 435817 367243 832923 951160 641047 99220 871028 287941 557278 971117 188193 426068 99955 903588 457858 657299 555419 828799 952391 593127 500701 216309 418072 314906 577440 491077 723301 659517 587027 132687 143048 684531 577461 86048 445416 533460 529814 1422 712901 963758 231724 73703 467167 203887 185226 171695 546828 281800 228151 380281 864617 834308 298943 365548 953139 107525 182827 806660 548515 677665 390556 30367 596179 455330 593484 138653 857421 595763 794835 584008 177588 573071 404519 809301 148897 22627 400297 372668 68757 432303 619518 794592 691878 610864 422046 797028 181421 561590 548059 81545…
Output: 918102

Example 3:

Input: 951 680 515992 283659 943416 324472 104798 464991 790465 826493 691554 274772 349965 901678 945543 980170 78633 148347 669851 3562 699451 481253 921007 996209 313774 335627 24685 315500 290439 884850 971091 294820 212603 436052 142476 715306 288728 96902 278834 277951 534829 936257 62655 232940 656042 386876 476267 929749 805466 801386 155778 333906 518116 142741 137249 829853 608375 769476 507758 632813 654932 241248 99324 535247 97811 1273 968016 719601 747075 747155 241651 787608 783597 760666 423588 438869 658084 440193 191659 2877 464388 696862 998708 11249 48277 502489 426141 872867 412154 397280 749284 513540 296420 523043 638309 981594 184854 247732 852210 541776 639923 550768 673254 412908 752052 77797 809839 358544 184091 931744 914330 503 942479 914996 917226 161382 325114 97977…
Output: 279327

Constraints:

1 <= k <= n <= 5779; 0 <= a[i] <= 1000000.

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