# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
819081 |
2023-08-10T07:56:23 Z |
LeVanThuc |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
332 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
if(x<y)
{
x=y;
return 1;
}
return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
if(x>y)
{
x=y;
return 1;
}
return 0;
}
void online()
{
std::ios_base::sync_with_stdio(0);
cin.tie(0);
//#ifndef ONLINE_JUDGE
// freopen("input.inp", "r", stdin);
// freopen("output.out","w", stdout);
//#else
//#endif
}
const ll M=1e9,N=1e5+10;
ll a[N],n,k;
int main()
{
online();
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
sort(a+1,a+n+1);
vector<ll> vt;
for(int i=2;i<=n;i++)
{
vt.push_back(a[i]-a[i-1]-1);
}
ll ans=a[n];
sort(vt.begin(),vt.end());
k--;
while(k--)
{
ans-=vt.back();
vt.pop_back();
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |