Submission #92128

#TimeUsernameProblemLanguageResultExecution timeMemory
92128tjrwodnjs999격자 보존하기 (GA9_preserve)C++11
56 / 100
25 ms2040 KiB
#include <cstdio> #include <algorithm> using namespace std; int l, n, k, a[100010], s[100010]; int main(){ scanf("%d%d%d", &l, &n, &k); for(int i = 0; i < n; i++) scanf("%d", a + i); sort(a, a + n); for(int i = 1; i < n; i++) s[i] = a[i] - a[i - 1] - 1; sort(s + 1, s + n); reverse(s + 1, s + n); for(int i = 1; i < n; i++) s[i] += s[i - 1]; if(k == 1) printf("%d", max(a[0] - 1, l - a[n - 1])); else if(k % 2) printf("%d", max(s[k / 2] + max(a[0] - 1, l - a[n - 1]), s[k / 2 - 1] + a[0] - 1 + l - a[n - 1])); else printf("%d", max(s[k / 2], s[k / 2 - 1] + a[0] - 1 + l - a[n - 1])); }

Compilation message (stderr)

preserve.cpp: In function 'int main()':
preserve.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &l, &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
preserve.cpp:9:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < n; i++) scanf("%d", a + 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...