Submission #1015533

#TimeUsernameProblemLanguageResultExecution timeMemory
1015533adkjtStove (JOI18_stove)C++14
0 / 100
0 ms344 KiB
#include<bits/stdc++.h> using namespace std; priority_queue<int> pq; int a[111111]; int main() { int n,k;cin>>n>>k; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=2;i<=n;i++) pq.push(a[i]-a[i-1]-1); int ans=0; int cnt=n-1; while(cnt>k){ ans+=pq.top(); pq.pop(); cnt--; } cout<<a[n]-ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...