Submission #547785

#TimeUsernameProblemLanguageResultExecution timeMemory
547785unicornboyStove (JOI18_stove)C++14
100 / 100
53 ms2796 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define ff first #define ss second using namespace std; const int N=5e5+1; int main() { ll n , k; cin >> n >> k ; ll arr[n+1]; ll v[n+1]; for (int i=0;i<n;i++) { cin >> arr[i]; if(i!=0) { v[i-1]=arr[i]-arr[i-1]-1; } } sort(v,v+n-1); ll ans=n; for (int i=0;i<n-k;i++) { ans+=v[i]; } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...