Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int N;
- int K;
- cin >> N;
- cin >> K;
- int a[N];
- for ( int i=0; i<N; i++)
- cin >> a[i];
- int l=0;
- int counter;
- int r=a[N-1];
- int d=a[N-1];
- while(1){
- if (r=l) {
- cout << l;
- return 0;
- }
- int q=0;
- counter=0;
- int z=0;
- if (counter > N) {
- l = d-1;
- d=(l + r)/2;
- }
- if (counter <= N) {
- r = d-1;
- d= (l + r) / 2;
- }
- while ( z <= N) {
- if (a[z]<a[q]+d) {
- z++;
- continue;
- }
- if (a[z]>=(a[q]+d)) {
- q=z;
- z++;
- counter++;
- continue;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement