# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28283 | ㅁㄴㅇㄹ (#68) | Wine Tasting (FXCUP2_wine) | C++98 | 96 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 n, k, i, T[300010];
long long res=0;
int main(){
scanf("%d%d", &n, &k);
for(i=0; i<n; i++)
scanf("%d", T+i);
sort(T, T+n);
for(i=0; i<k; i++){
if(i%2==0)
res+=T[n-i/2-1];
else
res-=T[i/2];
}
if((k-1)%2==1)
res+=T[(k-1)/2];
printf("%lld", res);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |