loj#P2332. 「JOI 2017 Final」焚风现象
「JOI 2017 Final」焚风现象
Description
In the Kingdom of IOI, the wind always blows from sea to land. There are spots numbered from to . The wind from Spot to Spot in order. Mr. JOI has a house at Spot . The altitude of Spot is , and thealtitude of Spot is .
The wind blows on the surface of the ground. The temperature of the wind changes according to the change ofthe altitude. The temperature of the wind at Spot , which is closest to the sea, is degree. For each the change of the temperature of the wind from Spot to Spot depends only on the values of and in the following way:
- If , the temperature of the wind decreases by degrees per altitude.
- If , the temperature of the wind increases by degrees per altitude.
The tectonic movement is active in the land of the Kingdom of IOI. You have the data of tectonic movements for days. In the -th day, the change of the altitude of Spot for is described by . If is not negative, the altitude increases by . If is negative, the altitude decreases by .
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 , the temperatur eof the wind at the house of Mr. JOI after the tectonic movement on the -th day.
Input
The first line of input contains four space separated integers . This means there is a house of Mr.JOI at Spot , there are tectonic movements, the temperature of the wind decreases by degrees per altitude if the altitude increases, and the temperature of the wind increases by degrees per altitude if the altitude decreases.
The -th line of the following lines contains an integer , which is the initial altitudeat Spot before tectonic movements.
The -th line of the following lines contains three space separated integers . This means, for the tectonic movement on the -th day, the change of the altitude at the spots from to is described by .
Output
Write lines to the standard output. The -th line of output contains the temperature of the windat the house of Mr. JOI after the tectonic movement on the -th day.
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
2 2 5 5
0
6
-1
1 1 4
1 2 8
5
-35
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
Constraints
All input data satisfy the following conditions:
Subtask
Subtask 1: 30 pts
Subtask 2: 10 pts
Subtask 3: 60 pts No additional constraints.