CT24875

The ledgers at Goldmeadow

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the trading post of Goldmeadow, Innkeeper the scribe keeps careful count of the ledgers. Prepare the guildmaster's brief, every figure matters. 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 <= 916; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 223 210 -376751 875811 350826 -469171 -5756 403873 706720 -438838 32298 -517208 -639146 719579 -483106 -727092 -784888 -366497 -813090 -110918 120161 318760 393227 489805 -203770 -269931 -792342 -102139 -365442 16180 -720723 110803 -74047 82267 280193 -703412 645283 923096 525594 464175 509162 -568800 -824495 -23511 646396 131774 994495 -200591 -131722 151642 286638 213236 787713 -665055 -656614 524982 358832 -151967 -382910 -570063 -42405 -180760 949646 -742887 761594 -221476 -205591 763170 377019 463875 -635646 74479 279108 -193799 842539 964102 -768185 915037 574841 768867 794967 764670 -633117 -781076 880767 -982886 -624732 573521 -430558 -799704 -732126 -941208 576503 -555421 -345431 519717 -142998 -921088 720390 -556027 -860207 -278656 -182032 -904399 281853 971990 -174842 -85154 877990 143788 561309 -248671 -675015 459893 512925 -764530 655695 126676 208905 -993962 -82676 928759 -138390 -431608 702187 -443591 716061 -348518 261585 625568 811531 -683533 49909 -414370 129542 -31946 195063 -421554 940429 -894810 -172352 -110176 30665 -685969 -119998 180118 61900 -78292 -287595 117788 345974 -656491 -154370 -575406 30679 255711 628626 656762 -913929 369754 348694 -79163 -705553 753636 -201000 414113 -263637 -518010 941969 -317658 -43255 -223572 -672656 729228 -968733 674978 301872 77247 757510 -152309 -322945 498103 827783 -208315 -466258 -983224 263995 -772828 -70936 -578109 327977 837137 -765630 -854485 935858 -694817 -585934 -200155 275005 -601450 854004 877526 717352 -907964 -74150 470162 457669 -245826 -511468 531071 -90535 594224 -584504 668798 479551 538712 -656005 -896370 840236 -325000 -689559 -510059 16577 -485522 -163972
Output: -824495

Example 2:

Input: 137 128 -47832 769316 692705 894214 -783014 824623 -964207 529321 -330114 735024 691325 -20374 -566534 557968 58934 -977490 -737487 -592442 -626299 335172 -396951 323488 -457800 -505161 -129573 -667256 -160412 -240193 149711 -750471 -738549 -25039 661974 43821 -744444 996403 618876 -451109 -464895 -274474 165215 30258 290812 373050 103499 -849283 -760196 -16897 37166 -265958 -208369 -967629 498790 112534 405541 -567261 577018 156711 -897778 -3534 209760 422319 -630037 475822 -113333 -239692 -625826 -626463 -224539 -357143 443289 -859446 96780 -663262 192309 729053 957708 -454047 -402652 -601935 383827 -726515 -79704 733637 -977009 595461 -581825 320036 23954 94364 434738 -476679 -225395 555689 -342176 -294109 3102 -310072 -848889 -806506 -460967 -915869 301047 53778 446951 -72461 -775463 365224 -7173 460272 -312679 578827 -272173 -510326 28145 913941 72308 -532814 849653 248118 227547 -251454 605312 688309 347827 24524 612448 246986 -337133 -987527 -136090 348887 -729728 947166 410853 145671 257663
Output: -848889

Example 3:

Input: 197 95 -883342 556868 513517 -14781 -136610 699440 -381767 -543277 511681 602396 -615927 57991 339377 -716812 -721856 140188 303294 -349949 585245 -64634 10148 185744 671975 594989 -945115 -735014 -837230 -499214 -526552 831709 -992924 -305116 -46416 -521823 194763 94312 -220456 -70042 -939610 -572569 -666010 -89210 -114806 209817 -788529 175391 -427870 720388 813866 -752725 -207954 -168913 43326 419546 164985 -453066 -169493 784415 490230 -173443 -34447 884040 -559186 536503 342803 -927622 831885 541491 -967677 -898559 -283552 -438395 720676 -867143 -365916 376583 347431 831870 -375283 234237 368102 494312 -468643 793184 913290 -104686 -25913 -202567 350643 -477546 983919 162197 985266 644699 -748159 772095 -376869 797514 137859 388642 -670585 -217055 -473753 420296 569718 969356 392863 -291329 -924866 403723 555289 -137172 -284274 -403260 -860169 -386298 834040 -737071 -732639 -793491 -273949 988531 -278486 -158059 -863618 -248398 -944875 -3800 964969 902561 673564 561836 724428 -407125 601018 -511166 -962410 -357655 147121 -662229 -76433 813392 -320493 -999511 471745 329115 366918 -780240 531973 -453951 857231 308916 -346270 -465771 -642521 1799 365823 195646 -682566 588246 328995 -849694 -213632 -248207 200360 905912 -771983 -429014 395224 584296 453425 653357 903983 -912233 356403 -546436 -125720 -463341 626939 -935388 -96845 -78652 -404307 475846 828814 685494 -251880 -445744 993393 -159504 955452 192487 -64327 585554 610624 69230 241388
Output: 1799

Constraints:

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

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