시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 150 | 99 | 90 | 65.217% |
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:
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.
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.
Read the following data from the standard input.
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.
All input data satisfy the following conditions.
번호 | 배점 | 제한 |
---|---|---|
1 | 30 | N ≤ 2 000, Q ≤ 2 000. |
2 | 10 | S = T. |
3 | 60 | There are no additional constraints. |
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
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.
2 2 5 5 0 6 -1 1 1 4 1 2 8
5 -35
This sample input satisfies the constraints of Subtask 2.
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
277 277 322 290 290 290 290 370