Submission #52348

#TimeUsernameProblemLanguageResultExecution timeMemory
52348tmwilliamlin168Stove (JOI18_stove)C++14
100 / 100
35 ms10076 KiB
#include <bits/stdc++.h> using namespace std; const int mxN=1e5; int n, k, t1, t2, ans, d[mxN-1]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(int i=0; i<n; ++i) { cin >> t2; if(i) d[i-1]=t2-t1-1; t1=t2; } ans=n; sort(d, d+n-1); for(int i=0; i<n-k; ++i) ans+=d[i]; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...