# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
866589 |
2023-10-26T13:09:39 Z |
maks007 |
Stove (JOI18_stove) |
C++14 |
|
0 ms |
348 KB |
#include "bits/stdc++.h"
using namespace std;
#define int long long
signed main () {
int n, k;
cin >> n >> k;
vector <int> a(n);
for(int i = 0; i < n; i ++) cin >> a[i];
function <int(int,int)> good=[&](int x, int opt) {
int cnt = 1, ff = a[0], ans = 0;
for(int i = 1; i < n; i ++) {
if(a[i]-ff > x) {
cnt ++;
ans += a[i-1]-ff+1;
ff = a[i];
}
}
ans += a[n-1]-ff+1;
if(opt) return ans;
if(cnt <= k) return 1LL;
return 0LL;
};
int l = 0, r = 1e9;
while(l < r) {
int mid = (l + r) / 2;
if(good(mid, 0)) r = mid;
else l = mid + 1;
}
cout << good(r, 1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |