제출 #1344952

#제출 시각아이디문제언어결과실행 시간메모리
1344952jumpStove (JOI18_stove)C++20
100 / 100
33 ms1536 KiB
#include <bits/stdc++.h>
#define int long long


signed main(){
	int n,k;
	std::cin >> n >> k;
	int fuel = n;
	std::priority_queue<int> pq;
	int last;
	std::cin >> last;
	for(int i=1;i<n;i++){
		int in;
		std::cin >> in;
		if(last-in+1==0)k+=1;
		else
		pq.push(last-in+1);
		last=in;
	}
	while(n>k){
		//std::cout << pq.top() << ' ';
		fuel-=pq.top();pq.pop();
		n--;
	}
	std::cout << fuel;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...