# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28269 | 뚜루루뚜루 (#68) | Wine Tasting (FXCUP2_wine) | C++98 | 99 ms | 4364 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 <bits/stdc++.h>
using namespace std;
long long arr[300009];
int main()
{
int n,k;
long long ans;
scanf("%d %d",&n,&k); --k;
for(int i=0; i<n; i++) scanf("%lld",&arr[i]);
sort(arr, arr+n);
ans = arr[n-1];
for(int i=0; i<(n-2)-i && i<k/2; i++) ans += arr[n-2-i] - arr[i];
printf("%lld",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |