CT24238

Jace's registers K-th Peak

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Caravans arrive at the crane marshes of Stillwater with crates of registers, and Jace the clerk must account for every last one. 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 <= 757; -1000000000 <= a[i] <= 1000000.

Example 1:

Input: 611 523 -801024425 -389048430 -46618623 -663527886 -690131181 -284730081 -257496744 -437345493 -733829225 -327232924 -980116911 -862484502 -162910727 -944300708 -356088885 -591937885 -769135752 -482953237 -551120683 -511206819 -783913073 -729384775 -344133635 -781182195 -71375964 -919920797 -447119771 -397098052 -150941253 -649693331 -304978621 -459318236 -38610547 -392598689 -823655723 -203371663 -773552546 -703723230 -574094403 -823709740 -652346280 -290780328 -710298213 -229420156 -967614103 -435368504 -456674990 -100508268 -671148098 -981660780 -362591692 -713514456 -76874560 -123552114 -638367493 -501155216 -580254865 -990674437 -946066112 -642687241 -489636624 -62718486 -787213601 -89142911 -643190120 -862259401 -921246349 -313654755 -987062298 -84873617 -699814012 -449570574 -162050…
Output: -839065120

Example 2:

Input: 2 1 -228615485 -715939225
Output: -228615485

Example 3:

Input: 716 337 -534354810 -3861326 -131002984 -526746104 -957718485 -910574232 -457260323 -548462715 -633795005 -53323669 -328084992 -889351620 -423020769 -969785989 -385738703 -205159845 -504469358 -198741890 -758962243 -18590419 -557306707 -518623196 -209228358 -778137317 -996567027 -494806001 -967558890 -626913320 -911076258 -396548169 -350383627 -82114486 -515771903 -55287027 -196450036 -981998256 -288192205 -363112385 -626748236 -468607674 -324073250 -146701007 -575962062 -329079639 -41733366 -342389728 -79708466 -453427254 -799807513 -37643201 -364198592 -527292087 -742857905 -723783112 -453007380 -502365245 -101007918 -522779710 -187736865 -442310537 -527325569 -87931386 -728113790 -472290558 -117437072 -486746459 -455727649 -445827715 -310027929 -31993406 -437709665 -946772185 -730343069 …
Output: -504034146

Constraints:

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

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