Submission #1083378

#TimeUsernameProblemLanguageResultExecution timeMemory
1083378quanquaiStove (JOI18_stove)C++17
100 / 100
18 ms2140 KiB
/** * author: anony * created: 02.09.2024 20:10:04 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> diff(n - 1); for (int i = 1; i < n; i++) { diff[i - 1] = a[i] - a[i - 1] - 1; } sort(diff.begin(), diff.end()); cout << accumulate(diff.begin(), diff.begin() + n - k, 0ll) + n; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...