Submission #20974

#TimeUsernameProblemLanguageResultExecution timeMemory
20974undecember격자 보존하기 (GA9_preserve)C++14
56 / 100
33 ms2408 KiB
#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)

preserve.cpp: In function 'int main()':
preserve.cpp:10:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &k, &d);
                             ^
preserve.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &lp);
                  ^
preserve.cpp:18:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &kp[i]);
                      ^

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...