이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define N 500005
#define sz size()
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pt pop_back
ll a[N], b[N], c, l, k, tr, b1, c1, d, t, n, h;
string s, g;
int main() {
ios::sync_with_stdio(false);cin.tie(0);
cin >> n >> k;
c = n - k;
h += n;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i++){
if(i + 1 <= n){
l ++;
b[l] = a[i + 1] - a[i] - 1;
}
}
sort(b + 1, b + l + 1);
// for(int i = 1; i <= l; i++)cout << b[i] << ' ';
// return 0;
for(int i = 1; i <= c; i++){
h += b[i];
}
cout << h<< '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |