N platforms, numbered 1 ~ N, the coordinate of station I is xi (0 = x0 <x1 <x2 ...). The cost of a platform to B station is xb-xa.m individual car, I people get on the bus at the ai station, bi station get off (1 <= ai <bi <= n ). When selling a ticket, a ticket conductor can select [c, d] (c <= d) from [a, B], which is not included in the fare. Half of the money conductor and the passengers are included in the ticket. Because the driver may check the ticket with pi in [xi, xi + 1], if someone finds that the ticket is not bought, the conductor c will be fined. Ask the conductor about the maximum expected earnings. Question: each person is independent, and the [xi, xi + 1] and [xi + 1, xi + 2] are also independent. Therefore, considering the maximum expected earnings of each person for the conductor separately, the total maximum expected earnings is the sum up. Set a passenger's a to B, that is, [a, B]. Consider [a, B] as [a, a + 1], [a + 1, a + 1],..., [B-1, B], a-B points, and each point has a weight value, which is its expected value. Then, the maximum consecutive sub-segment and value of the passenger's expectation for the conductor is [a, B. At this step, it is easy to think that this is a line segment tree with bare intervals. Code: [cpp] # include <stdlib. h> # include <string. h> # include <stdio. h> # include <ctype. h> # include <math. h> # include <stack> # include <queue> # include <map> # include <set> # include <vector> # include <string> # include <iostream> # include <algorithm> using namespace std; # define ll _ int64 # define ls rt <1 # define rs ls | 1 # define lson l, mid, ls # define rson mid + 1, r, rs # define middle (l + r)> 1 # define eps (1e-8) # define clr_all (x, c) memset (x, c, sizeof (x) # define clr (x, c, n) memset (x, c, sizeof (x [0]) * (n + 1) # define MOD 1000000007 # define INF 0x3f3f3f3f # define PI (acos (-1.0) # define _ mod (x, y) (x)> 0? (X) % (y) :( (x) % (y) + (y) % (y) # define _ abs (x) <0? (-(X) :( x) # define getmin (x, y) (x = (x) <0 | (y) <(x ))? (Y) :( x) # define getmax (x, y) (x = (y)> (x ))? (Y) :( x) template <class T> void _ swap (T & x, T & y) {T = x; x = y; y = t ;} template <class T> T _ max (T x, T y) {return x> y? X: y;} template <class T> T _ min (T x, T y) {return x <y? X: y;} int TS, cas = 1; const int M = 150000 + 5; int n, m; ll x [M], p [M], c; double val [M]; struct node {double lmax, rmax, mmax, sum; void init (int I) {lmax = rmax = mmax = sum = val [I];} nd [M <2]; void func (node & l, node & r, node & rt) {rt. sum = l. sum + r. sum; rt. lmax = _ max (l. lmax, l. sum + r. lmax); rt. rmax = _ max (r. rmax, r. sum + l. rmax); rt. mmax = _ max (l. mmax, r. mmax), l. rmax + r. lmax);} void pushUp (int rt) {func (nd [ls], nd [rs], nd [Rt]);} void build (int l, int r, int rt) {if (l = r) {nd [rt]. init (l); return;} int mid = middle; build (lson), build (rson); pushUp (rt);} node query (int l, int r, int rt, int L, int R) {if (L <= l & r <= R) {return nd [rt] ;}int mid = middle; if (R <= mid) return query (lson, L, R); if (mid <L) return query (rson, L, R); node lr = query (lson, l, mid); node rr = query (rson, mid + 1, R); node res; func (lr, rr, res); return res;} void ru N () {int I, j; for (I = 1; I <= n; I ++) scanf ("% I64d", & x [I]); n --; for (I = 1; I <= n; I ++) scanf ("% I64d", & p [I]); for (I = 1; I <= n; I ++) val [I] = 1.0 * p [I]/100.0*(1.0 * (x [I + 1]-x [I]) /2.0-1.0 * c) + (1.0-1.0 * p [I]/100.0) * (1.0 * (x [I + 1]-x [I]) /2.0); build (1, n, 1); int a, B; double ret = 0; while (m --) {scanf ("% d ", & a, & B); double tmp = query (1, n, 1, a, B-1 ). mmax; if (tmp> 0) ret + = tmp;} printf ("%. 9lf \ n ", ret);} www.2cto.com void preSof (){} Int main () {// freopen ("inputxt", "r", stdin); // freopen ("outputxt", "w", stdout); preSof (); // run (); while (~ Scanf ("% d % I64d", & n, & m, & c) run (); // for (scanf ("% d", & TS ); cas <= TS; cas ++) run (); return 0 ;}