제출 #52348

#제출 시각아이디문제언어결과실행 시간메모리
52348tmwilliamlin168Stove (JOI18_stove)C++14
100 / 100
35 ms10076 KiB
#include <bits/stdc++.h>
using namespace std;

const int mxN=1e5;
int n, k, t1, t2, ans, d[mxN-1];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i=0; i<n; ++i) {
		cin >> t2;
		if(i)
			d[i-1]=t2-t1-1;
		t1=t2;
	}
	ans=n;
	sort(d, d+n-1);
	for(int i=0; i<n-k; ++i)
		ans+=d[i];
	cout << ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…