이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**********************GOD**********************/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <iterator>
#include <map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll , ll> pll;
#define len length()
#define MP make_pair
#define fs first
#define sc second
#define pb(x) push_back(x)
#define all(x) x.begin() , x.end()
#define kill(x) cout << x , exit(0)
const ll INF = 1e18 + 8;
const ll MOD = 1e9 + 7;
const ll MXN = 2e5 + 6;
const ll LOG = 28 - 5;
ll n , k , ans;
ll lst;
multiset<ll> st;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> k;
for(ll i = 0 ; i < n ; i ++) {
ll x; cin >> x;
if(i)
st.insert(x - lst);
lst = x;
}
for(ll i = 0 ; i < n - k ; i ++)
ans += (*st.begin()) - 1 , st.erase(st.begin());
cout << ans + n;
return 0;
}
/*!
ahkh
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |