#D10439. Foehn Phenomena

    ID: 8672 Type: Default 1000ms 268MiB

Foehn Phenomena

Foehn Phenomena

In the Kingdom of IOI, the wind always blows from sea to land. There are N+1N + 1 spots numbered from 00 to NN. The wind from Spot 00 to Spot NN in order. Mr. JOI has a house at Spot NN. The altitude of Spot 00 is A0=0A_0 = 0, and the altitude of Spot ii (1iN1 \leq i \leq N) is AiA_i.

The wind blows on the surface of the ground. The temperature of the wind changes according to the change of the altitude. The temperature of the wind at Spot 00, which is closest to the sea, is 00 degree. For each ii (0iN10 \leq i \leq N - 1), the change of the temperature of the wind from Spot ii to Spot i+1i + 1 depends only on the values of AiA_i and Ai+1A_{i+1} in the following way:

  • If Ai<Ai+1A_i < A_{i+1}, the temperature of the wind decreases by SS degrees per altitude.
  • If AiAi+1A_i \geq A_{i+1}, the temperature of the wind increases by TT degrees per altitude.

The tectonic movement is active in the land of the Kingdom of IOI. You have the data of tectonic movements for QQ days. In the jj-th (1jQ1 \leq j \leq Q) day, the change of the altitude of Spot kk for LjkRjL_j \leq k \leq R_j (1LjRjN1 \leq L_j \leq R_j \leq N) is described by XjX_j. If XjX_j is not negative, the altitude increases by XjX_j. If XjX_j is negative, the altitude decreases by Xj|X_j|.

Your task is to calculate the temperature of the wind at the house of Mr. JOI after each tectonic movement.

Task

Given the data of tectonic movements, write a program which calculates, for each jj (1jQ1 \leq j \leq Q), the temperature of the wind at the house of Mr. JOI after the tectonic movement on the jj-th day.

Input

Read the following data from the standard input.

  • The first line of input contains four space separated integers NN, QQ, SS, TT. This means there is a house of Mr. JOI at Spot NN, there are QQ tectonic movements, the temperature of the wind decreases by SS degrees per altitude if the altitude increases, and the temperature of the wind increases by TT degrees per altitude if the altitude decreases.
  • The ii-th line (1iN+11 \leq i \leq N +1) of the following N+1N +1 lines contains an integer Ai1A_{i-1}, which is the initial altitude at Spot (i1i - 1) before tectonic movements.
  • The jj-th line (1jQ1 \leq j \leq Q) of the following QQ lines contains three space separated integers LjL_j, RjR_j, XjX_j. This means, for the tectonic movement on the jj-th day, the change of the altitude at the spots from LjL_j to RjR_j is described by XjX_j.

Output

Write QQ lines to the standard output. The jj-th line (1jQ1 \leq j \leq Q) of output contains the temperature of the wind at the house of Mr. JOI after the tectonic movement on the jj-th day.

Constraints

All input data satisfy the following conditions.

  • 1N2000001 \leq N \leq 200 000.
  • 1Q2000001 \leq Q \leq 200 000.
  • 1S10000001 \leq S \leq 1 000 000.
  • 1T10000001 \leq T \leq 1 000 000.
  • A0=0A_0 = 0.
  • $-1 000 000 \leq A_i \leq 1 000 000 (1 \leq i \leq N).$
  • 1LjRjN(1jQ)1 \leq L_j \leq R_j \leq N (1 \leq j \leq Q).
  • $ -1 000 000 \leq X_j \leq 1 000 000 (1 \leq j \leq Q).$

Sample Input and Output

Sample Input 1

3 5 1 2 0 4 1 8 1 2 2 1 1 -2 2 3 5 1 2 -1 1 3 5

Sample Output 1

-5 -7 -13 -13 -18

Initially, the altitudes of the Spot 0, 1, 2, 3 are 0, 4, 1, 8, respectively. After the tectonic movement on the first day, the altitudes become 0, 6, 3, 8, respectively. At that moment, the temperatures of the wind are 0, -6, 0, -5,respectively.

Sample Input 2

2 2 5 5 0 6 -1 1 1 4 1 2 8

Sample Output 2

5 -35

Sample Input 3

7 8 8 13 0 4 -9 4 -2 3 10 -9 1 4 8 3 5 -2 3 3 9 1 7 4 3 5 -1 5 6 3 4 4 9 6 7 -10

Sample output 3

277 277 322 290 290 290 290 370

Creatie Commons License

The 16th Japanese Olympiad in Informatics (JOI 2016/2017) Final Round

Example

Input

3 5 1 2 0 4 1 8 1 2 2 1 1 -2 2 3 5 1 2 -1 1 3 5

Output

-5 -7 -13 -13 -18

inputFormat

Input

Read the following data from the standard input.

  • The first line of input contains four space separated integers NN, QQ, SS, TT. This means there is a house of Mr. JOI at Spot NN, there are QQ tectonic movements, the temperature of the wind decreases by SS degrees per altitude if the altitude increases, and the temperature of the wind increases by TT degrees per altitude if the altitude decreases.
  • The ii-th line (1iN+11 \leq i \leq N +1) of the following N+1N +1 lines contains an integer Ai1A_{i-1}, which is the initial altitude at Spot (i1i - 1) before tectonic movements.
  • The jj-th line (1jQ1 \leq j \leq Q) of the following QQ lines contains three space separated integers LjL_j, RjR_j, XjX_j. This means, for the tectonic movement on the jj-th day, the change of the altitude at the spots from LjL_j to RjR_j is described by XjX_j.

outputFormat

Output

Write QQ lines to the standard output. The jj-th line (1jQ1 \leq j \leq Q) of output contains the temperature of the wind at the house of Mr. JOI after the tectonic movement on the jj-th day.

Constraints

All input data satisfy the following conditions.

  • 1N2000001 \leq N \leq 200 000.
  • 1Q2000001 \leq Q \leq 200 000.
  • 1S10000001 \leq S \leq 1 000 000.
  • 1T10000001 \leq T \leq 1 000 000.
  • A0=0A_0 = 0.
  • $-1 000 000 \leq A_i \leq 1 000 000 (1 \leq i \leq N).$
  • 1LjRjN(1jQ)1 \leq L_j \leq R_j \leq N (1 \leq j \leq Q).
  • $ -1 000 000 \leq X_j \leq 1 000 000 (1 \leq j \leq Q).$

Sample Input and Output

Sample Input 1

3 5 1 2 0 4 1 8 1 2 2 1 1 -2 2 3 5 1 2 -1 1 3 5

Sample Output 1

-5 -7 -13 -13 -18

Initially, the altitudes of the Spot 0, 1, 2, 3 are 0, 4, 1, 8, respectively. After the tectonic movement on the first day, the altitudes become 0, 6, 3, 8, respectively. At that moment, the temperatures of the wind are 0, -6, 0, -5,respectively.

Sample Input 2

2 2 5 5 0 6 -1 1 1 4 1 2 8

Sample Output 2

5 -35

Sample Input 3

7 8 8 13 0 4 -9 4 -2 3 10 -9 1 4 8 3 5 -2 3 3 9 1 7 4 3 5 -1 5 6 3 4 4 9 6 7 -10

Sample output 3

277 277 322 290 290 290 290 370

Creatie Commons License

The 16th Japanese Olympiad in Informatics (JOI 2016/2017) Final Round

Example

Input

3 5 1 2 0 4 1 8 1 2 2 1 1 -2 2 3 5 1 2 -1 1 3 5

Output

-5 -7 -13 -13 -18

样例

3 5 1 2
0
4
1
8
1 2 2
1 1 -2
2 3 5
1 2 -1
1 3 5
-5

-7 -13 -13 -18

</p>