Submission #75195

#TimeUsernameProblemLanguageResultExecution timeMemory
75195vexStove (JOI18_stove)C++14
100 / 100
33 ms8820 KiB
#include <bits/stdc++.h> #define maxn 100005 using namespace std; int n,k; long long t[maxn]; vector<long long>v; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>k; k--; for(int i=0;i<n;i++)cin>>t[i]; for(int i=1;i<n;i++)v.push_back(t[i]-t[i-1]-1); sort(v.begin(),v.end()); long long sol=t[n-1]+1-t[0]; int sz=v.size(); for(int i=sz-1;k>0;i--) { sol-=v[i]; k--; } cout<<sol<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...