시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 27 24 20 86.957%

문제

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

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 0, which is closest to the sea, is 0 degree. For each i (0 <=  i <= N - 1), the change of the temperature of the wind from Spot i to Spot i + 1 depends only on the values of Ai and Ai+1 in the following way:

  •  If Ai < Ai+1, the temperature of the wind decreases by S degrees per altitude.
  •  If Ai ≧ Ai+1, the temperature of the wind increases by T degrees per altitude.

The tectonic movement is active in the land of the Kingdom of IOI. You have the data of tectonic movements for Q days. In the j-th (1 <=  j <= Q) day, the change of the altitude of Spot k for Lj <= k <= Rj (1 <= Lj <= Rj <= N) is described by Xj. If Xj is not negative, the altitude increases by Xj. If Xj is negative, the altitude decreases by |Xj|.

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 j (1 <= j <= Q), the temperature of the wind at the house of Mr. JOI after the tectonic movement on the j-th day.

<Subtask>

  • Subtask 1 [30 points]
    The following conditions are satisfied.
    • N <= 2 000.
    • Q <= 2 000.
  • Subtask 2 [10 points]
    • S = T.
  • Subtask 3 [60 points]
    There are no additional constraints.

입력

Read the following data from the standard input.

  • The first line of input contains four space separated integers N; Q; S; T. This means there is a house of Mr. JOI at Spot N, there are Q tectonic movements, the temperature of the wind decreases by S degrees per altitude if the altitude increases, and the temperature of the wind increases by T degrees per altitude if the altitude decreases.
  • The i-th line (1 <= i <= N +1) of the following N +1 lines contains an integer Ai-1, which is the initial altitude at Spot (i - 1) before tectonic movements.
  • The j-th line (1 <= j <= Q) of the following Q lines contains three space separated integers Lj; Rj; Xj. This means, for the tectonic movement on the j-th day, the change of the altitude at the spots from Lj to Rj is described by Xj.

<Constraints>

All input data satisfy the following conditions.

  •  1 <= N <= 200 000.
  •  1 <= Q <= 200 000.
  •  1 <= S <= 1 000 000.
  •  1 <= T <= 1 000 000.
  •  A0 = 0.
  •  -1 000 000 <= Ai <= 1 000 000 (1 <= i <= N).
  •  1 <= Lj <= Rj <= N (1 <= j <= Q).
  •  -1 000 000 <= Xj <= 1 000 000 (1 <= j <= Q).

출력

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

예제 입력 1

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

예제 출력 1

-5
-7
-13
-13
-18

예제 입력 2

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

예제 출력 2

5
-35

예제 입력 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

예제 출력 3

277
277
322
290
290
290
290
370

힌트

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.