Submission #754624

#TimeUsernameProblemLanguageResultExecution timeMemory
754624Niko_shmikoStove (JOI18_stove)C++17
100 / 100
49 ms1056 KiB
#include<bits/stdc++.h> using namespace std; int n, k, t, ans; int main(){ cin >> n >> k; int a[n], in[n-1]; for(int i=0; i<n; i++){ cin >> a[i]; } ans=a[n-1]-a[0]+1; for(int i=0; i<n-1; i++){ in[i]=a[i+1]-a[i]-1; } sort(in, in+n-1); for(int i=0; i<k-1; i++){ ans-=in[n-2-i]; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...