Submission #1124833

#TimeUsernameProblemLanguageResultExecution timeMemory
1124833Rainmaker2627Stove (JOI18_stove)C++20
100 / 100
21 ms1988 KiB
#include<bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(false); int n, k; cin >> n >> k; vector<int> t(n); for (int i = 0; i < n; ++i) { cin >> t[i]; } sort(t.begin(), t.end()); vector<pair<int, int>> v; for (int i = 1; i < n; ++i) { v.push_back({t[i]-t[i-1]-1, i}); } sort(v.begin(), v.end()); int i=0, r=n; while (n-->k) r+=v[i++].first; cout << r << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...