Submission #1089450

#TimeUsernameProblemLanguageResultExecution timeMemory
1089450andrewkong972Stove (JOI18_stove)C++14
100 / 100
33 ms2004 KiB
#include <bits/stdc++.h> using namespace std; int main() { int sum = 0, cur1, cur2, n,k; cin >> n >> k; vector<int> dif; for (int i=0; i<n; i++) { cin >> cur1; if (i !=0) dif.push_back(cur1 - cur2 - 1); cur2 = cur1; } sort(dif.begin(), dif.end()); for (int i=0; i<n-k; i++) sum += dif[i]; cout << sum + n; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...