Submission #700056

#TimeUsernameProblemLanguageResultExecution timeMemory
700056dsyzStove (JOI18_stove)C++17
100 / 100
20 ms3216 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MAXN (1000005) int main() { ios_base::sync_with_stdio(false);cin.tie(0); ll N,K; cin>>N>>K; ll arr[N]; for(ll i = 0;i < N;i++){ cin>>arr[i]; } sort(arr,arr + N); vector<ll> gap; ll sum = N; for(ll i = 1;i < N;i++){ gap.push_back(arr[i] - (arr[i - 1] + 1)); } sort(gap.begin(),gap.end()); for(ll i = 0;i < N - K;i++){ sum += gap[i]; } cout<<sum<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...