CT22930

Last crates of June

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

June found an old ledger of crates in the dairy attic at the kelp forests of Tangledeep. The margin notes pose a precise question. 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 <= 540; -1000000000 <= a[i] <= 1000.

Example 1:

Input: 155 35 -227020476 -792767699 -901938174 -636242495 -505844930 -898315462 -176332642 -869194704 -860542835 -92701385 -599069865 -705758683 -120319347 -955694225 -770467589 -645017376 -434037284 -662686295 -171492645 -956121086 -850994552 -471472900 -345333587 -522019694 -876328203 -963018469 -320759256 -587365847 -559878768 -140473121 -254432228 -283197226 -475900564 -734147613 -774801702 -189851127 -769539467 -164568812 -724975237 -674586590 -619844430 -685597690 -570638926 -611824542 -563112936 -699654670 -563389924 -728058626 -587038985 -451644847 -234301449 -227786908 -258428396 -444663185 -169582470 -416728503 -648418765 -154954128 -215954021 -436588028 -979431306 -397827943 -719201258 -546439054 -192104009 -161096018 -687493388 -554421195 -385668807 -195335992 -357970065 -191033685 -1…
Output: -226918474

Example 2:

Input: 286 71 -511071258 -741194427 -868657744 -840045094 -314704161 -853860612 -611728954 -471191933 -419940175 -292588447 -115264660 -32486174 -346984240 -344110596 -833742619 -907355764 -707911923 -73871740 -99723103 -38162012 -321716510 -5062339 -640637691 -38686612 -920859228 -773298547 -509748981 -954658331 -960037305 -686394245 -987573634 -409651564 -592437815 -689834974 -596912174 -635643567 -39144750 -98819435 -854997336 -895548137 -888714020 -784145455 -504126413 -211736615 -360800482 -655876928 -73886262 -452829429 -612907194 -405800381 -37879989 -805501943 -772421240 -377118267 -639697873 -255875741 -728509968 -251934484 -342777818 -309461470 -92441412 -818141066 -482415494 -707877528 -978896064 -766992877 -487804610 -169879087 -483334834 -716073248 -661656179 -569805105 -419147278 -2…
Output: -274518620

Example 3:

Input: 215 116 -633819730 -930386147 -255135782 -346906733 -77464302 -495611470 -175223230 -897820150 -642583170 -574252569 -309457287 -41902719 -710794926 -668537285 -717902939 -180420397 -431746155 -119733854 -73321704 -570031749 -93714041 -225481697 -601320424 -128077065 -598608313 -356430498 -944130188 -672293243 -524150930 -948894851 -767239108 -12494423 -436595338 -594811028 -776837470 -547827023 -238075567 -629744004 -848808506 -682222459 -713616059 -485617452 -516722801 -142972413 -796057633 -462718333 -203659040 -407579124 -178308734 -919804943 -477349907 -265766586 -642411190 -773392138 -140485976 -634243224 -676126545 -670917147 -15841384 -788160118 -405942586 -506428462 -308065565 -305008751 -44640717 -801119306 -349056478 -870456172 -375560576 -276249085 -274953479 -976182220 -142782…
Output: -498277233

Constraints:

1 <= k <= n <= 540; -1000000000 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Last crates of June - EASY Coding Problem | CodeTikki