# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28485 | 핑응핑응 홍신정 (#68) | Wine Tasting (FXCUP2_wine) | C11 | 109 ms | 5804 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>
long long int t[300000];
long long int temp[300000];
void merge(long long int A[], int low, int high) {
int mid = (low + high) / 2;
int i = low, j = mid + 1, k = low;
while (i <= mid && j <= high) {
if (A[i]<A[j]) {
temp[k++] = A[i++];
}
else {
temp[k++] = A[j++];
}
}
for (; i <= mid; i++) {
temp[k++] = A[i];
}
for (; j <= high; j++) {
temp[k++] = A[j];
}
for (i = low; i <= high; i++)
A[i] = temp[i];
}
void mergesort(long long int A[], int low, int high) {
int mid = (low + high) / 2;
if (high>low) {
mergesort(A, low, mid);
mergesort(A, mid + 1, high);
merge(A, low, high);
}
}
int main() {
int num, k, i;
int start = 0, end;
long long int flavor = 0, tmp=0;
int flag = 1;
scanf("%d %d", &num, &k);
for (i = 0; i < num; i++) {
scanf("%lld", &t[i]);
}
mergesort(t, 0, num - 1);
end = num-1;
while (k--) {
if (flag == 1) {
flavor += (t[end--]-tmp);
flag = 0;
}
else {
tmp = t[start++];
flag = 1;
}
}
printf("%lld", flavor);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |