func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 303303;   const int Max = 101101;   int n, S, L;   int a[Max];   int lg[Max];   struct sparse {     int g, h;   };   sparse s[22][Max];   void build_table() {     for (int i = 1; i <= n; i++) {       s[0][i].g = a[i];       s[0][i].h = a[i];     }     for (int i = 1; i <= lg[n]; i++) {       for (int j = 1; j <= n - (1 << i) + 1; j++) {         s[i][j] = s[i - 1][j];         int G = s[i - 1][j + (1 << (i - 1))].g;         int H = s[i - 1][j + (1 << (i - 1))].h;         if (G < s[i][j].g) s[i][j].g = G;         if (H > s[i][j].h) s[i][j].h = H;       }     }     return;   }   int get_table(int L, int R) {     int len = R - L + 1;     int G1 = s[lg[len]][L].g;     int H1 = s[lg[len]][L].h;     int G2 = s[lg[len]][R - (1 << lg[len]) + 1].g;     int H2 = s[lg[len]][R - (1 << lg[len]) + 1].h;     int G, H;     if (G1 <= G2)       G = G1;     else       G = G2;     if (H1 >= H2)       H = H1;     else       H = H2;     int result = H - G;     return result;   }   int tree[Max * 11];   int get(int v, int L, int R, int pos) {     if (L == R) return tree[v];     if (pos <= (L + R) / 2)       return get(2 * v + 1, L, (L + R) / 2, pos);     else       return get(2 * v + 2, (L + R) / 2 + 1, R, pos);   }   int get_min(int v, int L, int R, int l, int r) {     if (l > R || L > r) return INF;     if (l <= L && R <= r) return tree[v];     int M1 = get_min(2 * v + 1, L, (L + R) / 2, l, r);     int M2 = get_min(2 * v + 2, (L + R) / 2 + 1, R, l, r);     if (M1 <= M2)       return M1;     else       return M2;   }   void push(int v, int L, int R, int pos, int num) {     if (L == R) {       tree[v] = num;       return;     }     if (pos <= (L + R) / 2)       push(2 * v + 1, L, (L + R) / 2, pos, num);     else       push(2 * v + 2, (L + R) / 2 + 1, R, pos, num);     tree[v] = tree[2 * v + 1];     if (tree[2 * v + 2] < tree[v]) tree[v] = tree[2 * v + 2];     return;   }   int main() {     cin >> n >> S >> L;     for (int i = 1; i <= n; i++) cin >> a[i];     lg[1] = 0;     int t = 1;     for (int i = 2; i <= n; i++) {       lg[i] = lg[i - 1];       if (t * 2 == i) {         t *= 2;         lg[i]++;       }     }     build_table();     for (int i = 0; i < Max * 11; i++) tree[i] = INF;     for (int i = L; i <= n; i++) {       int raz = get_table(i - L + 1, i);       if (raz <= S) {         int LL = 1;         int RR = i - L + 1;         int start;         while (true) {           if (LL == RR) {             start = LL;             break;           }           int MM = (LL + RR) / 2;           int raz_new = get_table(MM, i);           if (raz_new <= S)             RR = MM;           else             LL = MM + 1;         }         if (start == 1)           push(0, 1, n, i, 1);         else {           int dp = get_min(0, 1, n, start - 1, i - L);           if (dp != INF) push(0, 1, n, i, dp + 1);         }       }     }     int ans = get(0, 1, n, n);     if (ans == INF)       cout <<  -1  << endl;     else       cout << ans << endl;     return 0;   }   