func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int n, dp[MAXN], ans[MAXN], mx[4 * MAXN], lz[4 * MAXN];   vector<pair<int, int> > v, id;   void refresh(int pos, int bg, int ed) {     if (lz[pos] == 0) return;     int LZ = lz[pos];     lz[pos] = 0;     mx[pos] += LZ;     if (bg == ed) return;     lz[2 * pos] += LZ;     lz[2 * pos + 1] += LZ;   }   void upd(int pos, int bg, int ed, int p, int q, int val) {     refresh(pos, bg, ed);     if (q < bg || ed < p) return;     if (p <= bg && ed <= q) {       lz[pos] += val;       refresh(pos, bg, ed);       return;     }     int mid = (bg + ed) >> 1, l = 2 * pos, r = 2 * pos + 1;     upd(l, bg, mid, p, q, val);     upd(r, mid + 1, ed, p, q, val);     mx[pos] = max(mx[l], mx[r]);   }   int qry(int pos, int bg, int ed, int p, int q) {     refresh(pos, bg, ed);     if (q < bg || ed < p) return 0;     if (p <= bg && ed <= q) return mx[pos];     int mid = (bg + ed) >> 1, l = 2 * pos, r = 2 * pos + 1;     return max(qry(l, bg, mid, p, q), qry(r, mid + 1, ed, p, q));   }   int main() {     scanf( %d , &n);     for (int i = 0, x, h; i < n; i++) {       scanf( %d %d , &x, &h);       v.push_back(make_pair(x, x + h - 1));       id.push_back(make_pair(x, i));     }     sort(v.begin(), v.end());     sort(id.begin(), id.end());     dp[n - 1] = 1;     ans[id[n - 1].second] = 1;     upd(1, 0, n - 1, n - 1, n - 1, 1);     for (int i = n - 2; i >= 0; i--) {       int a = v[i].first;       int b = v[i].second;       int t = lower_bound(v.begin(), v.end(), make_pair(b + 1, (int)-1e9)) -               v.begin();       t--;       if (t == i)         dp[i] = 1;       else         dp[i] = qry(1, 0, n - 1, i + 1, t) + 1;       upd(1, 0, n - 1, i, i, dp[i]);       upd(1, 0, n - 1, i + 1, n - 1, 1);       ans[id[i].second] = dp[i];     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     printf(  n );   }   