CT26918

Morgana and the K-th Peak

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the garden city of Petalbrook, someone must document the rare sighting. This year the task falls to Morgana, armed only with the shelves 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 <= 398; 0 <= a[i] <= 1000.

Example 1:

Input: 67 49 291 50 1000 431 771 176 173 660 251 765 703 122 582 29 804 350 559 993 406 620 126 814 40 530 50 494 974 28 140 756 324 989 741 395 0 98 513 688 235 652 589 26 553 933 557 732 454 506 597 122 437 798 393 607 553 315 440 352 872 555 864 87 985 73 272 885 455
Output: 272

Example 2:

Input: 316 72 588 266 151 77 229 510 835 709 464 182 190 60 969 829 844 95 400 887 904 638 412 691 544 753 186 125 540 417 308 464 174 604 229 820 382 359 443 219 494 899 667 473 20 605 337 860 400 234 815 698 951 32 949 907 53 946 782 850 683 420 885 901 569 538 819 955 152 635 489 146 699 823 484 196 630 134 258 979 323 579 925 41 354 832 966 674 371 147 920 665 322 665 146 899 178 543 443 895 754 864 87 505 22 755 248 393 605 329 411 654 259 844 374 815 319 884 593 57 206 183 427 317 409 252 372 219 199 441 946 512 330 133 617 121 979 362 632 849 228 850 521 379 956 332 957 1 884 877 688 704 542 197 276 232 32 806 90 811 974 629 649 888 955 973 881 914 404 830 447 768 181 447 318 264 521 727 372 779 223 100 295 351 608 333 130 706 294 254 207 841 350 473 656 942 565 96 412 526 516 811 849 41 1…
Output: 811

Example 3:

Input: 162 160 530 568 92 500 35 510 365 138 799 140 153 298 117 285 970 738 445 290 928 553 528 426 86 24 786 257 755 524 413 290 949 324 984 155 85 975 671 510 504 319 725 807 549 633 803 730 903 802 647 251 533 358 870 230 589 847 42 223 911 262 7 260 656 299 109 183 327 222 12 983 31 989 496 6 124 775 90 285 172 73 968 981 291 294 91 984 500 26 137 848 67 408 301 654 280 929 64 52 0 747 296 799 432 369 494 189 651 35 307 495 763 737 618 497 889 937 1 400 785 908 163 930 530 957 32 688 541 8 993 799 840 909 937 151 200 212 237 691 83 813 802 420 525 102 411 562 897 575 171 807 520 156 131 329 145 704 415 128 371 922 433 122
Output: 6

Constraints:

1 <= k <= n <= 398; 0 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Morgana and the K-th Peak - EASY Coding Problem | CodeTikki