mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 07:58:52 +00:00
P3853 [TJOI2007]路标设置
R44439758
This commit is contained in:
parent
57de0429db
commit
b605576bc0
30
problem/P3853/P3853.cpp
Normal file
30
problem/P3853/P3853.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int l, r, n, k, a[100005];
|
||||
|
||||
bool check(int mid) {
|
||||
int m = 0;
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (a[i] - a[i - 1] >= mid) {
|
||||
m += (a[i] - a[i - 1]) / mid;
|
||||
if ((a[i] - a[i - 1]) % mid == 0) m--;
|
||||
}
|
||||
}
|
||||
return m <= k;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> r >> n >> k;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
while (l < r) {
|
||||
int mid = l + r >> 1;
|
||||
if (check(mid)) r = mid;
|
||||
else l = mid + 1;
|
||||
}
|
||||
cout << l << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user