#P1101F. Trucks and Cities
Trucks and Cities
No submission language available for this problem.
Description
There are cities along the road, which can be represented as a straight line. The -th city is situated at the distance of kilometers from the origin. All cities are situated in the same direction from the origin. There are trucks travelling from one city to another.
Each truck can be described by integers: starting city , finishing city , fuel consumption and number of possible refuelings . The -th truck will spend litres of fuel per one kilometer.
When a truck arrives in some city, it can be refueled (but refueling is impossible in the middle of nowhere). The -th truck can be refueled at most times. Each refueling makes truck's gas-tank full. All trucks start with full gas-tank.
All trucks will have gas-tanks of the same size litres. You should find minimum possible such that all trucks can reach their destinations without refueling more times than allowed.
First line contains two integers and (, ) — the number of cities and trucks.
The second line contains integers (, ) — positions of cities in the ascending order.
Next lines contains integers each. The -th line contains integers , , , (, , ) — the description of the -th truck.
Print the only integer — minimum possible size of gas-tanks such that all trucks can reach their destinations.
Input
First line contains two integers and (, ) — the number of cities and trucks.
The second line contains integers (, ) — positions of cities in the ascending order.
Next lines contains integers each. The -th line contains integers , , , (, , ) — the description of the -th truck.
Output
Print the only integer — minimum possible size of gas-tanks such that all trucks can reach their destinations.
Samples
Note
Let's look at queries in details:
- the -st truck must arrive at position from without refuelling, so it needs gas-tank of volume at least .
- the -nd truck must arrive at position from and can be refueled at any city (if it is on the path between starting point and ending point), so it needs gas-tank of volume at least .
- the -rd truck must arrive at position from , there is no city between, so it needs gas-tank of volume at least .
- the -th truck must arrive at position from and can be refueled only one time: it's optimal to refuel at -th city (position ) so it needs gas-tank of volume at least .
- the -th truck has the same description, so it also needs gas-tank of volume at least .
- the -th truck must arrive at position from and can be refueled two times: first time in city or and second time in city so it needs gas-tank of volume at least .