이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
ll n, k;
vector<int>t;
vector<int>restas;
void tc(){
cin >> n >> k;
for(int i = 0 ; i < n ; i ++){
int temp;
cin >> temp;
if(i > 0)restas.pb(temp - t.back() - 1);
t.pb(temp);
}
sort(restas.begin(), restas.end());
int total = t.back() + 1 - t[0];
for(int i = 0 ; i < k - 1 ; i ++){
if(!restas.empty()){
total -= restas.back();
restas.pop_back();
}
}
cout << total << "\n";
}
void end_tc(){
}
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(NULL);
int t = 1;
while(t--){
tc();
end_tc();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |