Submission #153341

#TimeUsernameProblemLanguageResultExecution timeMemory
153341mhy908Stove (JOI18_stove)C++14
100 / 100
27 ms2172 KiB
#include <bits/stdc++.h> int n, k, t[100010], arr[100010], ans; int main() { scanf("%d %d", &n, &k); for(int i=1; i<=n; i++)scanf("%d", &t[i]); for(int i=2; i<=n; i++)arr[i-1]=t[i]-t[i-1]-1; std::sort(arr+1, arr+n); ans=t[n]-t[1]+1; for(int i=n-1; i>=n-k+1; i--)ans-=arr[i]; printf("%d", ans); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:5: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:6:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%d", &t[i]);
                            ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...