제출 #468581

#제출 시각아이디문제언어결과실행 시간메모리
468581PiejanVDCStove (JOI18_stove)C++17
100 / 100
59 ms1868 KiB
#include <bits/stdc++.h>
using namespace std;

signed main() {
	int n,k; cin>>n>>k;
	int prev; cin>>prev;
	priority_queue<int>pq;
	for(int i = 1 ; i < n ; i++) {
		int x; cin>>x;
		pq.push(-x+prev+1);
		prev=x;
	}
	int ans=n;
	while(n > k) {
		ans+=-(pq.top());
		pq.pop();
		n--;
	}
	cout << ans;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...