CT31142

Nina's shelves K-th Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the gristmill of Rye Hollow, Nina records each shelves 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 <= 5117; 0 <= a[i] <= 1000000.

Example 1:

Input: 3087 1204 944449 527107 636014 963042 809687 97152 316824 467153 674076 822780 732679 419602 859514 64423 892090 144937 184659 470367 917878 993630 484334 280459 357509 376426 580715 847964 518935 711571 975698 401612 200198 988033 805046 141079 153634 507987 617433 996546 396710 286545 165381 697191 360422 304675 492317 386669 519814 880514 617584 531563 170555 173465 355317 4670 543778 465112 968968 423435 752910 16776 835213 954892 426906 974122 783491 346469 614901 170924 38464 849288 293822 593006 699216 130605 108461 152070 495481 290417 72479 915530 837970 845461 969309 641665 592218 557028 256328 373363 204405 88360 5391 737551 518340 135778 61884 157586 62722 581124 60476 198323 788979 481891 139921 812041 551401 240949 775606 886762 405816 368692 123451 542951 316637 179883 78141…
Output: 604028

Example 2:

Input: 4102 2080 95926 741008 619733 614857 27833 553955 594408 165748 899288 700744 755411 570160 722438 1505 156487 504566 306553 577475 848334 390751 42798 557025 37192 286195 536357 252548 169771 165241 425220 132901 204430 684142 711953 310163 368538 616695 514807 193301 296182 604237 837470 35973 391534 774065 988315 302768 682070 592759 100372 542774 145887 283594 769100 708334 108882 100223 765485 96140 753514 264273 946076 791369 766562 788379 102761 52169 935744 881473 389627 12345 363373 88389 349198 115196 884509 507936 170107 255308 828165 249967 428346 932739 198034 865258 561443 486132 540975 401485 782954 871308 758904 860792 497999 176816 538173 577044 302939 84605 447028 444708 791963 787047 530756 183036 240231 273370 122156 59051 261980 214691 746076 434813 246992 725294 94588…
Output: 479713

Example 3:

Input: 1056 620 145852 615002 484286 217669 705242 420379 479216 337648 297305 435524 892172 526208 213900 635681 646372 424737 967097 570269 339368 998667 946894 809230 474411 284756 630252 804912 504011 148704 38856 279581 31238 76142 292361 739521 28708 573410 115785 303847 133440 714264 262613 313225 957117 966147 862629 589541 960613 867764 752397 925426 906383 801962 498726 615554 457973 180012 481283 145359 312065 408017 975781 25491 778843 278272 739229 663732 613331 30210 411341 759998 649178 894133 202280 31099 674754 370562 96927 305012 320728 765839 653573 392168 837545 155514 182037 493757 904171 332976 375185 531440 633465 692025 811330 732734 726442 118702 848455 76142 867822 385400 441533 684583 603473 839697 64623 580135 957227 440873 42792 434251 283239 736889 635638 268041 9213…
Output: 426540

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nina's shelves K-th Peak - MEDIUM Coding Problem | CodeTikki