이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#include <functional>
int n, k, d, blank[10001];
int main()
{
int i, p;
int last = 0;
scanf("%d %d %d", &n, &k, &d);
for (i = 0; i < k; i++) {
scanf("%d", &p);
blank[i] = p - last - 1;
last = p;
}
blank[k] = n - last;
int first = blank[0];
last = blank[k];
sort(blank, blank+k+1, std::greater<int>());
int result = 0;
for (i = 0; d > 1; i++) {
result += blank[i];
if (first == blank[i]) {
first = 0;
d--;
} else if (last == blank[i]) {
last = 0;
d--;
} else {
d -= 2;
}
}
if (d == 1)
result += std::max(first, last);
else if (first + last > blank[i-1])
result = result - blank[i-1] + first + last;
printf("%d\n", result);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |