CT32026

Shimmering weights K-th Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the fjord village of Deepwater, someone must reconcile two mismatched ledgers. This year the task falls to Xanthe, armed only with the weights 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 <= 6837; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 466 394 627707 -19957 273486 -132779 -305569 686754 380446 -100778 -528304 -309946 640046 175237 -476102 -81264 -750955 -685799 411150 -514808 212573 -781190 -824475 675558 -756550 970038 755650 779744 667071 -476678 -503652 266447 -888808 -120401 803313 524676 -54364 -722242 808416 748311 -202619 636074 -698790 267471 -832656 556920 820405 138657 335074 812549 139407 115170 348798 262729 317401 -794410 327671 -718698 687861 920415 600495 -369258 -275784 544721 -753074 282936 -97475 947041 -947522 -269520 845193 -106903 893753 873308 -395192 373801 -266968 744491 -648446 -798298 856099 422322 40558 -76436 948463 406911 -924750 -181260 -737510 -754612 538984 -981144 451178 -999762 608378 358057 -345307 -10312 -503780 -618989 748750 992319 -84015 687068 -225988 -171491 -167482 256858 -743121…
Output: -727125

Example 2:

Input: 3505 913 -295807 -444102 790016 -162341 -734849 346600 -268785 373890 477234 478271 820026 783059 345712 -572382 -346835 -695179 643321 -18066 938586 -655782 633188 764176 -226216 -793315 366347 -793639 -931439 167134 -701940 754673 774657 659267 656189 746106 -824805 -373669 -608003 94119 -110778 834310 -193580 -410282 -606273 -100531 -862302 815217 -769937 731046 -788766 -480781 -366306 -569993 357494 -795807 -210757 40089 126674 547671 926159 131811 480487 -930335 897455 668276 -273143 623280 -965393 346074 403171 176302 -990348 250799 -532838 -130744 -551191 160841 -63066 711836 -520115 272929 604461 822307 940294 -102543 654900 -973660 -396342 -916584 835059 278094 470819 -580421 30841 672519 16739 -151077 -183796 -608996 -781967 220254 -860112 -921267 594246 552682 -798843 695196 -48…
Output: 478271

Example 3:

Input: 5289 4440 -516929 650749 16137 -413552 869178 182875 750655 617443 392508 613239 -881999 -219968 -949304 -14305 -641970 694825 -951552 309097 -809896 992073 -589990 -738382 303515 -115129 789794 -153706 845387 -530710 279829 -271499 -693897 390611 -484292 -415849 -39717 -415519 -432732 664504 927909 -455048 401725 241763 567856 572062 435191 697954 422419 189346 -629197 97856 522409 -765075 -24976 -892619 2499 11567 172683 823933 -581300 -71913 830507 749950 -568051 -109082 -934379 706424 -127639 -565833 924370 -566968 545630 -289006 625667 709666 185285 121778 -360487 -42393 1174 362073 -196740 367995 792396 -396455 743597 163494 953346 538270 -306883 -370588 -519394 362083 -628470 768672 597203 85620 952980 -314578 -2042 580155 32750 -260991 -107888 -11434 -945604 -963448 -656917 -721234…
Output: -672253

Constraints:

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

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