# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28486 | Fe (#68) | Wine Tasting (FXCUP2_wine) | C++98 | 103 ms | 3460 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<stdio.h>
#include<algorithm>
#define LL long long
using namespace std;
LL b[300005],minx,maxx;
int main(){
LL n,k,i;
scanf("%lld %lld",&n,&k);
for(i=0;i<n;i++) scanf("%lld",&b[i]);
sort(b,b+n);
if(k%2==0) k--;
for(i=0;i<k/2;i++) minx+=b[i];
k/=2;
k++;
for(i=n-1;i>=n-k;i--) maxx+=b[i];
printf("%lld\n",maxx-minx);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |