이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
#define ms(v) memset(v, -1, sizeof v)
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define INF 1e15
#define mp make_pair
#define itn int
#define N 100010
using namespace std;
int n, k;
int v[N];
int32_t main(){
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> k;
for(int i = 1;i <= n;i++){
cin >> v[i];
}
k--;
int res = v[n] - v[1] + 1;
priority_queue <int> pq;
for(int i = 2;i <= n;i++){
pq.push(v[i] - v[i-1] - 1);
}
while(k != 0){
int x = pq.top();
pq.pop();
res -= x;
k--;
}
cout << res << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |