# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28265 | not good but never sad (#68) | Wine Tasting (FXCUP2_wine) | C++98 | 119 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 <stdio.h>
#include <algorithm>
using namespace std;
int A[300300];
int main()
{
int N,K,c;
scanf ("%d %d",&N,&K);
for (int i=0;i<N;i++) scanf ("%d",&A[i]);
sort(A,A+N);
long long ans = 0;
for (int i=0,j=N-1,c=0;c<K;c++){
if (c % 2 == 0){
ans += A[j] - (i ? A[i-1] : 0);
i++; j--;
}
}
printf ("%lld\n",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |