Submission #648182

#TimeUsernameProblemLanguageResultExecution timeMemory
648182mareksbStove (JOI18_stove)C++14
100 / 100
21 ms1108 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, k,ans=0; cin>>n>>k; int a[n]; int b[n-1]; int dif = n-k; ans=n; //avoid biggest gaps for(int i=0;i<n;i++){ cin>>a[i]; if(i!=0){ b[i-1]=a[i]-a[i-1]-1; } } sort(b,b+n-1); for(int i=0;i<dif;i++){ ans+=b[i]; } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...