# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
466065 |
2021-08-17T16:13:17 Z |
fuad27 |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
204 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main () {
int n, k;
cin >> n >> k;
int t[n], d[n];
for(int i = 0;i<n;i++) {
cin >> t[i];
}
for(int i = 0;i<n-1;i++)d[i] = t[i+1] - t[i] - 1;
int ans =t[n-1] - t[0] + 1;
sort(d, d+n, greater<int>());
for(int i = 1;i<k;i++)ans-=d[i-1];
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |