Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- #include<set>
- #include<math.h>
- using namespace std;
- int A[1000];
- long long f(int a,int b)
- {
- long long min = 999999;
- long long m=1;
- for (int i = 0; i < a-1; i++)
- {
- if (abs(A[i + 1] - A[i]) >= b)
- {
- m++;
- }
- }
- return m;
- }
- int main()
- {
- long long a,b;
- cin >> a>>b;
- for (int i = 0; i < a; i++)
- {
- cin >> A[i];
- }
- long long l = 0;
- long long r = 10000000000;
- int m;
- while ((l + 1) < r)
- {
- m = (l + r) / 2;
- if (f(a, m) >= b)
- {
- l = m;
- }
- else
- {
- r = m;
- }
- }
- cout << r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement