# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28443 | 탕탕탕! 핑거팁 니 맘을 겨눌게~ (#68) | Wine Tasting (FXCUP2_wine) | C11 | 0 ms | 1116 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 <stdlib.h>
int compare(void *first, void *second)
{
if (*(int*)first > *(int*)second)
return 1;
else if (*(int*)first < *(int*)second)
return -1;
else
return 0;
}
int main()
{
int N, K, i, result = 0;
int temp = 0, prev = 0;
int *arr;
scanf("%d %d", &N, &K);
arr = (int*)malloc(sizeof(int)*N);
for (i = 0; i < N; i++) {
scanf("%d", &arr[i]);
}
qsort(arr, N, sizeof(int), compare);
for (i = 1; i <= K; i++) {
if (i % 2 == 1) {
temp = arr[N - i];
if (i == 1)
result += temp;
else
result += temp - prev;
}
else {
prev = arr[i - 2];
}
}
printf("%d", result);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |