Submission #127215

#TimeUsernameProblemLanguageResultExecution timeMemory
127215gaoxam123Stove (JOI18_stove)C++14
100 / 100
88 ms1652 KiB
#include<bits/stdc++.h> using namespace std; int n,k; int a[100005]; int main(){ vector<int> ans; cin>>n>>k; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=2;i<=n;i++){ ans.push_back(a[i]-a[i-1]); } sort(ans.begin(),ans.end()); int cnt=k; for(int i=0;i<n-k;i++){ cnt+=ans[i]; } cout<<cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...