이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
vector<int> u;
int32_t main(){
cin >> n >> k;
k--;
for (int i = 0; i < n; i++){
cin >> a;
u.pb(a);
}
sort(u.begin(), u.end(), greater<int>());
for (int i = 0; i < n-1; i++){
v.push(u[i]-u[i+1]);
// cout << u[i]-u[i+1] << endl;
}
while(k > 0){
k--;
// cout << v.top()-1 << endl;
mak -= (v.top()-1);
v.pop();
}
cout << u[0]+mak << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |