Submission #96499

#TimeUsernameProblemLanguageResultExecution timeMemory
96499pamajStove (JOI18_stove)C++14
100 / 100
33 ms2168 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long; const int maxn = 1e5 + 10; int n, k, t[maxn], d[maxn]; int32_t main() { ios::sync_with_stdio(false), cin.tie(nullptr); cin >> n >> k; for(int i = 0; i < n; i++) { cin >> t[i]; if(i) d[i] = t[i] - t[i - 1] - 1; } int ans = 0; sort(d + 1, d + n); for(int i = 0; i < n - k; i++) { ans += d[i + 1]; } cout << ans + n << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...