Submission #1106061

#TimeUsernameProblemLanguageResultExecution timeMemory
1106061lufychopStove (JOI18_stove)C++14
100 / 100
39 ms3272 KiB
#include <bits/stdc++.h> using namespace std; long long t[100001]; int main(void) { long long n,k,ans; cin>>n>>k; k--; priority_queue<long long> q; for(int i=0;i<n;i++) { cin>>t[i]; } q.push(0); for(int i=1;i<n;i++) { q.push(t[i]-t[i-1]-1); } ans=t[n-1]-t[0]+1; while(k--) { ans=ans-q.top(); q.pop(); } cout<<ans; return 0; } /* 3 3 1 3 6 1 0 3 1 6 2 10 5 1 2 5 6 8 11 13 15 16 20 1 0 1->3 2 0 5 2 5->9 6 0 8 1 11 2 11->14 13 1 15 1 15->17 16 0 20 3 20->21 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...