# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
648188 |
2022-10-05T16:35:14 Z |
matissh |
Stove (JOI18_stove) |
C++14 |
|
0 ms |
212 KB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll n,k;
cin >> n >> k;
ll a[n];
for(ll i = 0;i < n;i++)
{
cin >> a[i];
}
sort(a,a+n);
ll ans=a[n-1];
vector<ll> v;
v.push_back(a[0]-1);
for(ll i = 1;i < n;i++)
{
v.push_back(a[i]-a[i-1]-1);
}
sort(v.begin(),v.end());
k--;
for(ll i = v.size()-1;k!=0;i--)
{
ans-=v[i];
k--;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 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 |
212 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 |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |