# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886435 | 2023-12-12T07:05:12 Z | artixkrishna | Stove (JOI18_stove) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; using ll= long long; int main(){ int n, k, a[1e5+5]; vector<int> res; for(int i=0; i<=n; i++){ cin>>a[i]; if(i>1) res.push_back(a[i]-a[i-1]); } sort(res.begin(), res.end()); int ans =n; for(int i=0; i<n-k; i++){ ans+=res[i]-1; } cout<<ans; }