Submission #392325

#TimeUsernameProblemLanguageResultExecution timeMemory
392325wildturtleStove (JOI18_stove)C++14
100 / 100
60 ms3224 KiB
#include<bits/stdc++.h> #define ll long long #define f first #define sc second using namespace std; ll a,b,c,d,i,e,f,g,n,m,k,l,idx,B[500005],le,ri,mid,ans; ll A[500005]; vector <ll> v; int main() { cin>>n>>k; for(ll i=1;i<=n;i++) { cin>>A[i]; } if(n==1) { cout<<1; return 0; } sort(A+1,A+1+n); for(ll i=1;i<n;i++) { v.push_back(A[i+1]-A[i]-1); } sort(v.begin(),v.end()); g=v.size()-k+1; for(ll i=v.size()-1;i>=max(f,g);i--) { a+=v[i]; } cout<<(A[n]+1)-A[1]-a; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...