Submission #12071

#TimeUsernameProblemLanguageResultExecution timeMemory
12071ainta격자 보존하기 (GA9_preserve)C++98
100 / 100
28 ms1876 KiB
#include<stdio.h> #include<algorithm> using namespace std; int C1, C2, C[101000], w[101000]; int L, n, K, Res; void Do(int S, int m){ if (m < 0)return; int i; for (i = n - 1; i >= 1; i--){ m -= 2; if (m < 0)break; S += C[i]; } if (Res < S)Res = S; } int main() { int i; scanf("%d%d%d", &L, &n, &K); for (i = 1; i <= n; i++){ scanf("%d", &w[i]); } C1 = w[1] - 1; C2 = L - w[n]; for (i = 1; i < n; i++){ C[i] = w[i + 1] - w[i] - 1; } sort(C + 1, C + n); if (C1 > C2)swap(C1, C2); Do(0,K); Do(C2, K - 1); Do(C1 + C2, K - 2); printf("%d\n", Res); }
#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...