CT33131

Aria and the K-th Mark

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the spice bazaar of Saffronia, Aria studies rows of ledgers entries. One clean number will settle the guild's oldest argument. Task: Print the k-th smallest element (1-based; duplicates count separately). Input format: First line: n and k. Second line: n integers. Output format: Print the k-th smallest value. Constraints: 1 <= k <= n <= 5889; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 4711 457 16470 385400 -209847 -312370 -973696 869965 740273 910977 -400914 -352585 -983032 -753763 994085 -60142 -240147 424216 927354 615658 -429600 -529219 -846892 -272090 -396186 -337688 587554 -846731 806444 782732 757971 -822266 -528122 276669 -58978 99877 875987 -319011 -892532 772802 -27283 983010 -890982 -717792 502792 589743 -42244 -666626 -903623 -781757 -303814 -924451 513845 -614482 639761 569029 -44402 -409886 338543 129510 -320993 99369 -615038 335624 -218490 -789851 -706728 213846 -901150 426970 -795610 480061 663089 -342760 781172 -317194 -539592 -747632 390466 323983 623653 847213 -449744 -646656 598733 -711054 -251011 -798140 -89839 550650 -967801 592462 961538 -559042 -786555 -213351 -839634 -711870 -120602 -777686 662762 -166005 742566 157968 -570908 -793469 -876158 -12…
Output: -804624

Example 2:

Input: 4531 1756 149617 793888 -852592 -658487 815965 618609 598265 -986984 345390 -611315 -401509 -526033 -515407 116687 -782134 -51829 -725342 -75954 102176 679830 -160250 423684 339049 -472425 -976424 770790 -558850 757615 -340758 -629730 -358737 -127405 -776276 857351 -399370 -936660 299009 -168793 -172558 -677649 -804444 922770 -372922 -747972 -732789 945956 -911691 574397 111497 -242532 -399058 -921991 210715 -868115 -805864 -246438 821967 358230 727092 -653753 458142 -919837 71661 88793 -563957 715115 41785 -614128 766259 -620208 -538129 169894 211800 -369952 184341 17488 -929283 -334787 -388709 -442309 597594 -357359 -423470 818262 -848107 28900 799539 -253828 -747550 260862 665483 450050 -446330 -214094 648212 -615928 329601 -65873 -568008 -887925 -773020 658673 -668562 -897630 999169 15…
Output: -223356

Example 3:

Input: 5048 4427 -929794 -809545 -182753 691940 512799 -959844 680666 73284 731233 956313 -319867 324093 -687480 -142301 -46702 -440244 -212943 513604 -817962 -780328 828876 9692 -881566 -704160 -48391 -784276 903286 657989 73144 839726 799558 -115349 -975624 503737 -813169 -969233 -716173 375997 799548 -826010 571391 223588 -50081 312087 135224 863031 -308148 -882292 454797 600169 293979 79653 -30115 106606 378008 -791001 -544546 435657 -265844 -237591 234562 365181 -458811 340582 361897 557653 334086 -19688 -370576 542235 -696279 -92483 -274812 823058 60410 486141 657488 -921590 553284 -432943 -957161 -106643 -608716 -382523 -587625 570370 137384 767215 424689 -848124 7447 -716826 269078 644792 297420 29453 -319198 -816560 854475 425319 -40134 -197456 986822 -168599 754965 -393437 -91313 -98934…
Output: 755822

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Aria and the K-th Mark - MEDIUM Coding Problem | CodeTikki