Submission #20977

#TimeUsernameProblemLanguageResultExecution timeMemory
20977kimjihoon격자 보존하기 (GA9_preserve)C++98
48 / 100
0 ms1160 KiB
#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)

preserve.cpp: In function 'int main()':
preserve.cpp:7:34: 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:9:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
                        ^

#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...