# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1089845 |
2024-09-17T09:50:18 Z |
Frostidian |
Stove (JOI18_stove) |
C++14 |
|
1 ms |
344 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int MX = 1e5 + 5;
int a[MX], sa = 0, n, k;
priority_queue < int > pq;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
for ( int i = 1; i <= n; i++ ){
cin >> a[i];
if ( i >= 2 ) pq.push(a[i] - a[i - 1] - 1);
sa += ( a[i] - a[i - 1] - 1 );
}
for ( int i = 1; i <= k - 1; i++ ){
sa -= pq.top(); pq.pop();
}
cout << sa + n << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |