Submission #365831

#TimeUsernameProblemLanguageResultExecution timeMemory
365831_zheksenovStove (JOI18_stove)C++17
100 / 100
56 ms1772 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; signed main() { int n, k; cin >> n >> k; vector<int> a(n); for (int& x : a) cin >> x; for (int i = 0; i < n; i++) { if (i > 0) { a[i - 1] = a[i] - a[i - 1] - 1; } } sort(a.begin(), a.end() - 1); ll ans = n; for (int i = 0; i < n - k; i++) { ans += a[i]; } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...