#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
int N, K;
cin>>N>>K;
int kada[N];
for(int i = 0; i<N; i++)
{
cin>>kada[i];
}
priority_queue<int> q;
int praeitas = kada[0];
for(int i = 1; i<N; i++)
{
q.push(kada[i] - praeitas - 1);
praeitas = kada[i];
}
int ats = kada[N-1] - kada[0];
for(int i = 0; i<K-1; i++)
{
ats-=q.top();
q.pop();
}
cout<<ats;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |