Submission #366585

#TimeUsernameProblemLanguageResultExecution timeMemory
366585EJOI2019AndrewStove (JOI18_stove)C++14
100 / 100
52 ms2156 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; int arr[n],arr1[n-1]; for(int i=0; i<n; ++i) { cin>>arr[i]; if(i) arr1[i-1]=arr[i]-arr[i-1]-1; } sort(arr1,arr1+n-1); int ans=n; for(int i=0; i<n-k; ++i) ans+=arr1[i]; cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...