Submission #48910

#TimeUsernameProblemLanguageResultExecution timeMemory
48910faustaadpStove (JOI18_stove)C++17
100 / 100
43 ms10288 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ll n,k,i,a[101010],has; vector<ll> v; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>k; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<n;i++) v.pb(a[i+1]-a[i]-1); sort(v.begin(),v.end()); for(i=0;i<n-k;i++) has+=v[i]; has+=n; cout<<has<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...