제출 #483624

#제출 시각아이디문제언어결과실행 시간메모리
483624ymmStove (JOI18_stove)C++17
100 / 100
19 ms2160 KiB
///
///   You fell for it, fool!
///   Thunder Cross Split Attack!
///

#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
typedef long long ll;
using namespace std;

const int N = 100'010;
int t[N], u[N];
int n, k;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k; --k;
	Loop(i,0,n) cin >> t[i];
	Loop(i,0,n-1) u[i] = t[i+1]-t[i]-1;
	sort(u,u+n-1,greater<int>());
	int ans = t[n-1]-t[0]+1;
	Loop(i,0,k) ans -= u[i];
	cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...