Submission #126350

#TimeUsernameProblemLanguageResultExecution timeMemory
126350EntityITStove (JOI18_stove)C++14
100 / 100
28 ms2088 KiB
#include<bits/stdc++.h> using namespace std; const int N = (int)1e5 + 5; int n, K, a[N], dist[N], ans; int main () { scanf("%d %d", &n, &K); for (int i = 0; i < n; ++i) scanf("%d", a + i); for (int i = 1; i < n; ++i) dist[i] = a[i] - a[i - 1] - 1; sort(dist + 1, dist + n); ans = n; for (int i = 1; i <= n - K; ++i) ans += dist[i]; printf("%d", ans); return 0; }

Compilation message (stderr)

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