이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define foreach for
#define in :
using namespace std;
typedef long long ll;
/*
Konichiwa
Konichiwa
Ara ~~ ara
Bob no taisuki - Shinobu Kocho
* * * * *
* *
* *
* * I love SHINOBU <3 <3 <3
* *
* *
* * * * *
*/
/*
_________________________
Author : Bob15324
_________________________
*/
template<class X , class Y>
bool Minimize(X & x , Y y)
{
if(x == -1 || x >y)
{
x = y;
return true;
}
return false;
}
template<class X , class Y>
bool Maximize(X & x , Y y)
{
if( x < y)
{
x = y;
return true;
}
return false;
}
/* End of templates. Let's see what do we have here */
const int N = 1e5+1;
int n , k;
int a[N];
int main()
{
ios_base :: sync_with_stdio(0);cin.tie(0);
cin >> n >> k;
int kay = n;
int res = n;
priority_queue<int , vector<int> , greater<int> >pq;
for(int i = 1 ; i <= n ; i++)
{
cin >> a[i];
if(i > 1)
{
pq.push(a[i] - a[i-1] - 1);
}
}
while(kay > k && !pq.empty())
{
res += pq.top();
pq.pop();
kay--;
}
cout << res ;
return 0;
}
//Ehem. My code is amazing. Pay me 2$.Thank you.
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |