Submission #466056

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