CT34000

Rohan's Silent weights

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the rookery of Crowhaven, someone must track the breeding season. This year the task falls to Rohan, 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 <= 5125; -1000000 <= a[i] <= 1000.

Example 1:

Input: 1450 113 -166076 -524497 -321622 -485464 -638050 -262072 -491264 -607871 -175236 -372257 -843070 -391255 -661236 -203558 -676234 -100407 -242894 -195567 -268303 -811034 -9917 -595159 -524737 -873556 -594847 -270428 -185375 -977917 -26372 -352778 -811010 -552247 -989980 -329944 -68968 -734037 -796155 -430840 -934055 -991179 -917505 -192873 -217137 -847848 -200 -841317 -573493 -2372 -387520 -662350 -833379 -589323 -684213 -948479 -128718 -363533 -531486 -443448 -228107 -530384 -439526 -498787 -943577 -242907 -549725 -636737 -688322 -84707 -643006 -909631 -108749 -549662 -535050 -976006 -718761 -643781 -38007 -16422 -424423 -63698 -156936 -522781 -425621 -197873 -460009 -350882 -102360 -87487 -762686 -433913 -968691 -898710 -39334 -871741 -13623 -124849 -779494 -578606 -987260 -857624 -601734…
Output: -75663

Example 2:

Input: 4756 3603 -10746 -623007 -892838 -764126 -366284 -612248 -369420 -438837 -41115 -46885 -267221 -420982 -479164 -298531 -632210 -286783 -623682 -667114 -625299 -381862 -964364 -417104 -662732 -560164 -917921 -595434 -447926 -178514 -808753 -82657 -805454 -179463 -810625 -407086 -449205 -947606 -859496 -863609 -468218 -424025 -318137 -798307 -463906 -674316 -337897 -937829 -757154 -599170 -898520 -112180 -617790 -540096 -83119 -313233 -908420 -383944 -144226 -190341 -162880 -473672 -119215 -253736 -514557 -207773 -478655 -251985 -182052 -784060 -815846 -555811 -665681 -545142 -411884 -789101 -253128 -604245 -914720 -297132 -212920 -53134 -5627 -873314 -690347 -938664 -543508 -983478 -552230 -687143 -297611 -198533 -732637 -283544 -251308 -609481 -486574 -94021 -73836 -184246 -860451 -780112 …
Output: -755384

Example 3:

Input: 3225 2205 -394131 -459428 -772426 -500281 -273767 -157265 -995674 -766506 -889619 -251613 -756910 -56288 -706827 -665534 -649883 -687349 -915275 -495763 -136575 -810341 -859107 -829052 -727636 -397318 -118262 -227647 -944314 -70661 -857660 -932028 -351528 -26710 -503683 -445523 -377973 -841655 -766019 -717737 -547716 -17576 -660485 -967445 -479382 -930031 -280271 -875748 -166554 -108073 -926391 286 -491162 -539003 -969319 -990814 -379833 -811455 -108006 -612705 -151897 -171797 -837391 -490217 -458209 -381447 -393810 -806005 -630781 -524647 -146932 -510045 -866719 -482969 -46671 -118907 -820436 -325923 -87195 -581938 -826829 -132678 -295816 -236822 -364556 -882679 -315611 -150519 -885551 -652479 -94196 -192926 -980619 -959027 -1472 -205962 -868395 -22313 -399070 -480410 -191617 -128654 -111…
Output: -691142

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rohan's Silent weights - MEDIUM Coding Problem | CodeTikki