Submission #466065

#TimeUsernameProblemLanguageResultExecution timeMemory
466065fuad27Stove (JOI18_stove)C++17
0 / 100
0 ms204 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int32_t main () { int n, k; cin >> n >> k; int t[n], d[n]; for(int i = 0;i<n;i++) { cin >> t[i]; } for(int i = 0;i<n-1;i++)d[i] = t[i+1] - t[i] - 1; int ans =t[n-1] - t[0] + 1; sort(d, d+n, greater<int>()); for(int i = 1;i<k;i++)ans-=d[i-1]; cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...