Submission #103425

#TimeUsernameProblemLanguageResultExecution timeMemory
103425AllianceStove (JOI18_stove)C++14
100 / 100
96 ms2420 KiB
// In the name of Allah. Ya ali! #include<bits/stdc++.h> #define double long double typedef long long ll; const ll MAX_N = 1e5+10; const ll MOD = 1e9+7; using namespace std; int a[MAX_N]; int n,k; ll ans; int main() { cin >> n >> k; for(int i = 1;i<=n;++i) cin >> a[i]; ans = n; vector<int> vc; sort(a+1,a+n+1); for(int i = 2;i<=n;++i) vc.push_back(a[i]-a[i-1]-1); sort(vc.begin(),vc.end()); for(int i = 0;i<n-k;++i) ans += vc[i]; cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...