func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int NMAX = 300010;   const double E = 1e-8;   const double PI = acos(-1);   int n, m, stest;   int d;   set<long long> St;   long long st[NMAX], h[NMAX];   pair<int, int> Tree[4 * NMAX];   int dp[NMAX], trace[NMAX];   pair<int, int> cmp(pair<int, int> a, pair<int, int> b) {     if (a.first > b.first)       return a;     else       return b;   }   void update(int i, int lo, int hi, int u, int x, int vt) {     if (lo == hi) {       Tree[i] = cmp(Tree[i], pair<int, int>(x, vt));       return;     }     int mid = (lo + hi) >> 1;     if (u <= mid)       update(2 * i, lo, mid, u, x, vt);     else       update(2 * i + 1, mid + 1, hi, u, x, vt);     Tree[i] = cmp(Tree[2 * i], Tree[2 * i + 1]);   }   pair<int, int> query(int i, int lo, int hi, int u, int v) {     if (v < lo || hi < u) return pair<int, int>(0, 0);     if (u <= lo && hi <= v) return Tree[i];     int mid = (lo + hi) >> 1;     return cmp(query(2 * i, lo, mid, u, v), query(2 * i + 1, mid + 1, hi, u, v));   }   void truy(int x) {     if (x == 0) return;     truy(trace[x]);     cout << x <<    ;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> d;     for (int i = 1; i <= n; i++) {       cin >> h[i];       St.insert(h[i]);       St.insert(h[i] - d);       St.insert(h[i] + d);     }     for (set<long long>::iterator it = St.begin(); it != St.end(); it++)       st[++m] = *it;     int ans = 0, vt = 0;     for (int i = 1; i <= n; i++) {       int pos = lower_bound(st + 1, st + m + 1, h[i]) - st;       int u = lower_bound(st + 1, st + m + 1, h[i] - d) - st;       int v = lower_bound(st + 1, st + m + 1, h[i] + d) - st;       pair<int, int> res = cmp(query(1, 1, m, 1, u), query(1, 1, m, v, m));       dp[i] = res.first + 1;       trace[i] = res.second;       update(1, 1, m, pos, dp[i], i);       if (dp[i] > ans) {         ans = dp[i];         vt = i;       }     }     cout << ans << endl;     truy(vt);     return 0;   }   