#P3655. Aqours Charm Calculation

    ID: 16906 Type: Default 1000ms 256MiB

Aqours Charm Calculation

Aqours Charm Calculation

Aqours has N+1 members standing in a row with singing ability values A[0] to A[N]. The leader stands at the front with A[0] = 0 and is never affected by any operations. The remaining members (indices 1 through N) have initial singing abilities given in the input.

A special machine can modify the singing abilities of a consecutive group of members by adding an integer Z (which may be negative) to each affected member. You will use this machine Q times. Each operation is given as three numbers X, Y, and Z, which means that you add Z to each member from index X to index Y (1-indexed).

After each operation, the charm value B of the lineup is computed as follows. Initially, B = 0. Then for each i from 1 to N, let d = A[i] - A[i-1]. If d is positive (i.e. A[i-1] A[i]), add T \(\cdot\) |d| to B. Here S and T are given constants. Your task is to output the charm value B after each operation.

Note: Only members with indices 1 through N are updated by the machine, and the leader A[0] always remains 0.

inputFormat

The first line contains four integers N, Q, S, and T.

The second line contains N+1 integers representing A[0] to A[N] (with A[0] always equal to 0).

Each of the next Q lines contains three integers X, Y, and Z, meaning that you add Z to each member from index X to index Y (1-indexed).

outputFormat

After each operation, output the resulting charm value B on a new line.

sample

5 3 2 3
0 1 3 2 2 4
2 4 1
1 3 -2
2 5 3
-7

-6 -12

</p>