# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28346 | :thinking_face: (#68) | Wine Tasting (FXCUP2_wine) | C++11 | 109 ms | 3192 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;
int arr[300000];
long long ret = 0;
int main()
{
int n, k;
scanf("%d %d", &n, &k);
for(int i = 0; i < n; i++)
scanf("%d", arr+i);
sort(arr, arr+n);
int l = 0, r = n-1;
bool right = true;
long long ret = 0;
int prev = 0;
while(k--)
{
if(right)
ret += arr[r--] - prev;
else
prev = arr[l++];
right = !right;
}
printf("%lld\n", ret);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |