func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXPOW = 20;   const int MAXA = 1048577;   const int MAXN = 100009;   const int MAXM = 100009;   const int INF = 1e9 + 7;   struct Node {     Node(int val) : val(val) {}     int val;   };   struct MinIntervalTree {     MinIntervalTree(int n, int val) {       N = 1;       while (N < n) {         N *= 2;       }       nodes.resize(N * 2 + 2, Node(val));     }     int getMin(int L, int R) { return getMin(0, 0, N, L, R + 1); }     void set(int x, int val) { set(0, 0, N, x, val); }       private:     int getMin(int v, int L, int R, int A, int B) {       if (L == A && R == B) {         return nodes[v].val;       }       int M = (L + R) / 2;       if (B <= M) {         return getMin(v * 2 + 1, L, M, A, B);       }       if (A >= M) {         return getMin(v * 2 + 2, M, R, A, B);       }       return min(getMin(v * 2 + 1, L, M, A, M), getMin(v * 2 + 2, M, R, M, B));     }     void set(int v, int L, int R, int P, int val) {       if (L + 1 == R) {         nodes[v] = val;         return;       }       int M = (L + R) / 2;       if (P < M) {         set(v * 2 + 1, L, M, P, val);       } else {         set(v * 2 + 2, M, R, P, val);       }       nodes[v].val = min(nodes[v * 2 + 1].val, nodes[v * 2 + 2].val);     }     int N;     vector<Node> nodes;   };   void testTree() { MinIntervalTree t(10, 1e9); }   int main() {     ios::sync_with_stdio(false);     int n, s, l;     cin >> n >> s >> l;     vector<int> a(n);     vector<int> maxLeft(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];       maxLeft[i] = 0;     }     set<pair<int, int> > aliveUp;     set<pair<int, int> > aliveDown;     for (int i = n - 1; i >= 0; --i) {       {         auto it = aliveUp.lower_bound(make_pair(a[i] + s + 1, 0));         while (it != aliveUp.end()) {           aliveUp.erase(it);           maxLeft[it->second] = max(maxLeft[it->second], i + 1);           it = aliveUp.lower_bound(make_pair(a[i] + s + 1, 0));         }       }       {         auto it = aliveDown.lower_bound(make_pair(-a[i] + s + 1, 0));         while (it != aliveDown.end()) {           aliveDown.erase(it);           maxLeft[it->second] = max(maxLeft[it->second], i + 1);           it = aliveDown.lower_bound(make_pair(-a[i] + s + 1, 0));         }       }       aliveUp.insert(make_pair(a[i], i));       aliveDown.insert(make_pair(-a[i], i));     }     for (int i = 1; i < n; ++i) {       maxLeft[i] = max(maxLeft[i], maxLeft[i - 1]);     }     vector<int> dp(n + 1, 1e9);     MinIntervalTree T(n + 3, 1e9);     dp[0] = 0;     T.set(0, 0);     for (int i = 0; i < n; ++i) {       int L = maxLeft[i] - 1 + 1;       int R = i - l + 1;       if (L > R) {         continue;       }       dp[i + 1] = 1 + T.getMin(L, R);       T.set(i + 1, dp[i + 1]);     }     if (dp[n] >= 1e9) {       cout << -1 << endl;     } else {       cout << dp[n] << endl;     }     return 0;   }   