Submission #534881

#TimeUsernameProblemLanguageResultExecution timeMemory
534881amunduzbaevStove (JOI18_stove)C++17
100 / 100
18 ms2364 KiB
#include "bits/stdc++.h" using namespace std; #define ar array const int N = 1e5 + 5; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n, k; cin>>n>>k; k--; vector<int> a(n), t; for(int i=0;i<n;i++) cin>>a[i]; int res = a[n - 1] - a[0] + 1; for(int i=0;i + 1<n;i++){ t.push_back(a[i+1] - a[i] - 1); } sort(t.rbegin(), t.rend()); for(int i=0;i<k;i++) res -= t[i]; cout<<res<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...