이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
///#define pragma GCC optimise("O3")
using namespace std;
signed main()
{
int n, k; cin>>n>>k;
vector <int> dif;
int aux=0, all=0;
for (int i=1; i<=n; i++)
{
int a; cin>>a;
if (i>1) dif.push_back(a-aux);
if (i==1) all=a;
if (i==n) all=a+1-all;
aux=a+1;
}
sort(dif.begin(), dif.end(), greater<int>());
k--;
for (auto x:dif)
{
k--;
all-=x;
if (k==0) break;
}
cout<<all<<endl;
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... |