# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28331 | lyzqm123 (#68) | Wine Tasting (FXCUP2_wine) | C++11 | 0 ms | 2288 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
using namespace std;
int arr[300001];
int main() {
int N, K;
scanf("%d%d", &N, &K);
for (int n = 0;n < N;n++) scanf("%d", &arr[n]);
sort(arr, arr + N);
long long ans = arr[N - 1];
if (N >= 2 && K > 2)
ans += arr[N - 2] - arr[0];
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |