# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28590 | 탕탕탕! 핑거팁 니 맘을 겨눌게~ (#68) | Wine Tasting (FXCUP2_wine) | C11 | 0 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>
int wine[300000], flag[300000];
int main() {
int N, K, i, j, min, max, pre_min, min_index, max_index;
long long int flavor = 0;
scanf("%d %d", &N, &K);
for (i = 0; i < N; i++)
scanf("%d", &wine[i]);
i = 0;
while (i < K) {
min = 1000000001, max = -1;
for (j = 0; j < N; j++) {
if (max < wine[j] && flag[j] == 0) { max = wine[j]; max_index = j; }
if (min > wine[j] && flag[j] == 0) { min = wine[j]; min_index = j; }
}
flag[max_index] = 1, flag[min_index] = 1;
if (i == 0) {
flavor = max;
pre_min = min;
i++;
continue;
}
else flavor += (max - pre_min);
pre_min = min;
i = i + 2;
}
printf("%lld", flavor);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |