# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20974 | undecember | 격자 보존하기 (GA9_preserve) | C++14 | 33 ms | 2408 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 <bits/stdc++.h>
using namespace std;
int n, k, d;
int mp[2], kp[100005];
int main(void)
{
scanf("%d%d%d", &n, &k, &d);
int ans = 0;
int lp;
scanf("%d", &lp);
mp[0] = lp - 1;
for (int i = 0; i < k - 1; i++)
{
scanf("%d", &kp[i]);
kp[i] = kp[i] - lp - 1;
lp = kp[i] + lp + 1;
}
mp[1] = n - lp;
sort(mp, mp + 2);
sort(kp, kp + (k - 1));
int rst = 2 * k - d;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 2; j++)
{
int tv = n - k - i * mp[0] - j * mp[1];
int r = rst - i - j;
if (r < 0) continue;
int ki;
for (ki = 0; r >= 2 && ki < k - 1; ki++)
{
tv -= kp[ki];
r -= 2;
}
if (r > k - ki - 1) continue;
if (r % 2) tv -= kp[ki];
if (tv > ans) ans = tv;
}
}
printf("%d", ans);
}
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... |