Submission #1112169

#TimeUsernameProblemLanguageResultExecution timeMemory
1112169nikolashamiStove (JOI18_stove)C++17
100 / 100
20 ms1508 KiB
#include <bits/stdc++.h> using namespace std; int a[(int)1e5+4]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,k; cin>>n>>k; for(int i=0;i<n;++i) cin>>a[i]; vector<int>d; for(int i=1;i<n;++i) d.push_back(a[i]-a[i-1]-1); sort(d.rbegin(),d.rend()); int t=a[n-1]-a[0]+1; for(int i=0;i<k-1;++i) t-=d[i]; cout<<t; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...