Submission #843924

#TimeUsernameProblemLanguageResultExecution timeMemory
843924Elvin_FritlStove (JOI18_stove)C++17
100 / 100
46 ms2340 KiB
#include <bits/stdc++.h> using namespace std; const int N = 25; int32_t main() { int n,k; cin>>n>>k; int a[n+1]; for(int i=1;i<=n;i++){ cin>>a[i]; } int res = a[n] + 1 - a[1]; priority_queue<int>q; for(int i=2;i<=n;i++){ q.push(a[i] - a[i-1] - 1); } k--; while(k--){ res -= q.top(); q.pop(); } cout<<res<<endl; return 0; } /* 1 1 2 2 3 3 4 4 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...