Submission #204698

#TimeUsernameProblemLanguageResultExecution timeMemory
204698bogdan_ogorodniyStove (JOI18_stove)C++14
100 / 100
86 ms2292 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5 * 1e3 + 1; const int inf = 1e9 + 7; signed main() { int n, k; cin >> n >> k; vector <int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; vector <int> vv; int dist = 0; for (int i = 1; i < n; i++) { vv.push_back(v[i] - v[i - 1]); } sort(vv.begin(), vv.end()); for (int i = 0; i < n - k; i++) dist += vv[i]; dist += k; cout << dist << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...