Submission #127196

#TimeUsernameProblemLanguageResultExecution timeMemory
127196tuanasanhStove (JOI18_stove)C++11
100 / 100
96 ms2244 KiB
#include<bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; const int N=1e5+50; int a[N],d[N]; int n,k,ans; signed main(){ // freopen(".inp","r",stdin); // freopen(".out","w",stdout); // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k; ans=n; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n-1;i++) d[i]=a[i+1]-a[i]-1; sort(d,d+n-1); for(int i=0;i<n-k;i++) ans+=d[i]; cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...