Submission #1063005

#TimeUsernameProblemLanguageResultExecution timeMemory
1063005warrennStove (JOI18_stove)C++14
100 / 100
36 ms3284 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int n,k; cin>>n>>k; int a[n+1]; for(int q=1;q<=n;q++){ cin>>a[q]; } vector<int>cek; for(int q=1;q<n;q++){ int has=a[q+1]-a[q]-1; cek.push_back(has); } int ans=a[n]-a[1]+1; sort(cek.rbegin(),cek.rend()); for(int q=0;q<k-1;q++){ ans-=cek[q]; } cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...