Submission #1105790

#TimeUsernameProblemLanguageResultExecution timeMemory
1105790YouKnowCipherStove (JOI18_stove)C++17
0 / 100
1 ms440 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int int32_t main () { int n, k; cin >> n >> k; vector<int> v(n), res(n - 1); for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = 1; i < n; i++) { res[i - 1] = v[i] - v[i - 1] - 1; } sort(res.begin(), res.end(), greater<int>()); int cost = 0; for (int i = 0; i < k - 1; i++) { cost += res[i]; } cout << max(n, *max_element(v.begin(), v.end()) - cost) << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...