Submission #127203

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