Submission #153340

#TimeUsernameProblemLanguageResultExecution timeMemory
153340mhy908Stove (JOI18_stove)C++14
100 / 100
29 ms2936 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; int n, k; LL t[100010], arr[100010], ans; int main() { scanf("%d %d", &n, &k); for(int i=1; i<=n; i++)scanf("%lld", &t[i]); for(int i=2; i<=n; i++)arr[i-1]=t[i]-t[i-1]-1; sort(arr+1, arr+n, greater<LL>()); ans=t[n]-t[1]+1; for(int i=1; i<=k-1; i++)ans-=arr[i]; printf("%lld", ans); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:8: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:9: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("%lld", &t[i]);
                            ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...