func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Act {     int l, r;     int mx;     double pb;     vector<Act *> son;     static int dp_size;     double dp[5005];     bool operator<(const Act &act) const {       if (l < act.l) {         return true;       } else if (l > act.l) {         return false;       } else if (r > act.r) {         return true;       }       return false;     }     bool contains(Act &act) { return act.l >= l && act.r <= r; }     double p(int profit) {       if (profit < 0) return 0.0;       if (profit > dp_size) return 1.0;       return dp[profit];     }   };   int Act::dp_size = 0;   int n, q;   int *a;   int **m;   int *lg;   Act act[5005];   void dfs(Act &act) {     for (int i = 0; i < act.son.size(); i++) {       dfs(*act.son[i]);     }     for (int i = 0; i <= Act::dp_size; i++) {       act.dp[i] = 0.0;     }     for (int i = 0; i <= Act::dp_size; i++) {       double p = (i == 0 ? 0.0 : act.pb);       double np = 1.0 - act.pb;       for (int j = 0; j < act.son.size(); j++) {         Act *son = act.son[j];         p *= son->p(act.mx - son->mx + i - 1);         np *= son->p(act.mx - son->mx + i);       }       act.dp[i] = p + np;     }   }   int main() {     cin >> n >> q;     a = new int[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     lg = new int[n + 1];     lg[1] = 0;     for (int i = 2; i <= n; i++) {       lg[i] = lg[i / 2] + 1;     }     m = new int *[lg[n] + 1];     for (int i = 0; i <= lg[n]; i++) {       m[i] = new int[n];     }     for (int i = 0; i < n; i++) {       m[0][i] = a[i];     }     for (int i = 1; i <= lg[n]; i++) {       int psz = 1 << (i - 1);       int nsz = 1 << i;       for (int j = 0; j + nsz <= n; j++) {         m[i][j] = max(m[i - 1][j], m[i - 1][j + psz]);       }     }     q++;     for (int i = 0; i < q; i++) {       if (i == q - 1) {         act[i].l = 1;         act[i].r = n;         act[i].pb = 0.0;       } else {         cin >> act[i].l >> act[i].r >> act[i].pb;       }       act[i].l--, act[i].r--;       int tlg = lg[act[i].r - act[i].l + 1];       int tsz = 1 << tlg;       act[i].mx = max(m[tlg][act[i].l], m[tlg][act[i].r - tsz + 1]);     }     sort(act, act + q);     Act::dp_size = q;     for (int i = 1; i < q; i++) {       int j = i - 1;       while (!act[j].contains(act[i])) j--;       act[j].son.push_back(act + i);     }     dfs(act[0]);     double ans = 0.0;     for (int i = 0; i <= Act::dp_size; i++) {       ans += (act[0].mx + i) * (act[0].p(i) - act[0].p(i - 1));     }     printf( %.8lf , ans);     return 0;   }   