# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20977 | kimjihoon | 격자 보존하기 (GA9_preserve) | C++98 | 0 ms | 1160 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 n, k, d, a, m[11111], c, t;
int main()
{
scanf("%d %d %d", &n, &k, &d);
for(int i = 1; i <= k; i++){
scanf("%d", &a);
m[i] = a-t-1;
t = a;
}
m[k+1] = n - t;
if(d % 2 == 0)m[1] += m[k+1];
else {
if(m[1] > m[k+1]){c += m[1]; m[1] = m[k+1];}
else c += m[k+1];
}
sort(m+1, m+k+1);
for(int i = k; k-i+1 <= d/2 && k-i+1 <= k; i--)c += m[i];
printf("%d\n", c);
return 0;
}
Compilation message (stderr)
# | 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... |