이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h> //needa retype template incase bret reynold yeah bruh moment ill me
using namespace std;
#define int long long
typedef pair<int,int>pii;
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,k;
cin >> n >> k;
int arr[n+5];
for(int x=1;x<=n;x++){
cin >> arr[x];
}
priority_queue<int,vector<int>,greater<int>>pq;
for(int x=2;x<=n;x++){
pq.push(arr[x]-arr[x-1]-1);
}
int counter=n;
for(int bruh=0; bruh<n-k; ++bruh) {
auto cur=pq.top();
counter+=cur;
pq.pop();
}
cout << counter;
}
/*
10 5
1
2
5
6
8
11
13
15
16
20
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |