Submission #278059

#TimeUsernameProblemLanguageResultExecution timeMemory
278059AhmetYahyaStove (JOI18_stove)C++17
0 / 100
1 ms256 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long int
#define pb push_back
#define st first
#define nd second
#define lb lower_bound

const int N = 4000050;

int n, k, a, b, mak;
priority_queue<int > v;

int32_t main(){
	cin >> n >> k;
	k--;
	cin >> b;
	mak = b;
	for (int i = 1; i < n; i++){
		cin >> a;
		v.push(a-b);
		// cout << a-b << endl;
		b = a;
		mak = max(a, mak);
	}
	while(k > 0){
		k--;
		mak -= (v.top()-1);
		v.pop();
	}
	cout << mak << endl; 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...