Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int N;
  7.     int K;
  8.     cin >> N;
  9.     cin >> K;
  10.    
  11.     int a[N];
  12.     for ( int i=0; i<N; i++)
  13.         cin >> a[i];
  14.     int l=0;
  15.     int counter;
  16.     int r=a[N-1];
  17.     int d=a[N-1];
  18.     while(1){
  19.         if (r=l) {
  20.             cout << l;
  21.             return 0;
  22.         }
  23.  
  24.  
  25.         int q=0;
  26.         counter=0;
  27.         int z=0;
  28.           if (counter > N) {
  29.             l = d-1;
  30.             d=(l + r)/2;
  31.         }
  32.         if (counter <= N) {
  33.             r = d-1;
  34.             d= (l + r) / 2;
  35.             }
  36.         while ( z <= N)  {
  37.             if (a[z]<a[q]+d) {
  38.                     z++;
  39.                     continue;
  40.                 }
  41.             if (a[z]>=(a[q]+d)) {
  42.                 q=z;
  43.                 z++;
  44.                 counter++;
  45.                 continue;
  46.             }
  47.         }
  48.      
  49.  
  50.  
  51.         }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement