Submission #1124879

#TimeUsernameProblemLanguageResultExecution timeMemory
1124879sinatbtfardStove (JOI18_stove)C++20
100 / 100
17 ms1476 KiB
#include <bits/stdc++.h> using namespace std; int main (){ ios_base::sync_with_stdio(0); int n, k; cin >> n >> k; vector <int> a(n), dif; for (int &i : a) cin >> i; for (int i = 1; i < n; i++) dif.push_back(a[i] - a[i - 1]); sort(dif.begin(), dif.end()); int ans = 0; for (int i = 0; i < n - k; i++) ans += dif[i]; cout << ans + k; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...