Submission #1062352

#TimeUsernameProblemLanguageResultExecution timeMemory
1062352ducksaysquackStove (JOI18_stove)C++98
100 / 100
40 ms2980 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, k; cin >> n >> k; vector<int> v(n); for(int i=0;i<n;i++) cin >> v[i]; vector<int> w(n-1); for(int i=0;i<n-1;i++) w[i] = v[i+1]-v[i]-1; sort(begin(w),end(w)); int ans = v[n-1]-v[0]+1; for(int i=n-2;i>n-k-1;i--) ans -= w[i]; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...