이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
long long int N,K,horatotal;
int main(){
while(cin>>N>>K){
vector <long long int> horainicio(N);
vector <long long int> rangoespera(N-1);
for(int a=0;a<N;a++){
cin>>horainicio[a];
}
horatotal=horainicio[N-1]-horainicio[0]+1;
for(int a=0;a<N-1;a++){
rangoespera[a]=horainicio[a+1]-horainicio[a]-1;
}
sort(rangoespera.rbegin(),rangoespera.rend());
for(int a=0;a<K-1;a++){
horatotal-=rangoespera[a];
}
cout<<horatotal<<'\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... |