Created
April 3, 2023 06:01
-
-
Save modos/7bc5ebc3286da5f060cf116481bd8355 to your computer and use it in GitHub Desktop.
کاف کیک
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n, k = map(int, input().split()) | |
arr = list(map(int, input().split())) | |
arrCopy = arr.copy() | |
result = -1 | |
arr.sort() | |
if k == 1: | |
result = arr[-1] | |
elif k == 2: | |
result = min(arrCopy[0], arrCopy[-1]) | |
else: | |
result = arr[0] | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment