# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
165912 |
2019-11-29T14:39:22 Z |
Sparky_09 |
Stove (JOI18_stove) |
C++17 |
|
2 ms |
376 KB |
#include<bits/stdc++.h>
#ifdef LOCAL_DEFINE
#include<conio.h>
#endif
using namespace std;
void io();
void end();
int main(){
io();
int n, k;
cin>>n>>k;
vector<int> p, v(n);
if(n==1){
cout << 1 << endl;
return 0;
}
for(int i = 0; i < n; i++){
cin>>v[i];
if(i!=0) p.push_back(v[i]-v[i-1]-1);
}
if(k>=n){ cout << n << endl; return 0; }
sort(p.rbegin(), p.rend());
int ans = v[n-1];
for(int i = 0; i < k-1; i++){
ans-=p[i];
}
cout << ans << endl;
end();
}
void io(){
#ifdef LOCAL_DEFINE
ios_base::sync_with_stdio(0); cin.tie(0);
freopen("input.txt", "rt", stdin);
#endif
}
void end(){
#ifdef LOCAL_DEFINE
cerr << "\nTime Elapsed: " << 1.0 * clock()/CLOCKS_PER_SEC << " s.\n";
getch();
#endif
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
252 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
252 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
252 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |