#P7189. Truck Parking Fee Calculation

    ID: 20393 Type: Default 1000ms 256MiB

Truck Parking Fee Calculation

Truck Parking Fee Calculation

Luka just graduated and started a job as a truck driver. One night, he parked his three trucks in a parking lot. The parking fee is charged according to the number of trucks parked at the same time:

  • If only one truck is parked in a minute, the fee for that minute is \(a\) for that truck.
  • If two trucks are parked in a minute, the fee for that minute is \(b\) per truck (i.e. a total of \(2b\)).
  • If three trucks are parked in a minute, the fee for that minute is \(c\) per truck (i.e. a total of \(3c\)).

Each truck is parked during a given time interval. For a truck parked from time \(s\) to \(e\), it is considered to be parked during each minute \(t\) such that \(s \le t < e\). Given the rates \(a\), \(b\), \(c\) and the three trucks' parking time intervals, compute the total parking fee Luka must pay.

inputFormat

The input consists of four lines:

  1. The first line contains three integers \(a\), \(b\), and \(c\) \( (1 \le a, b, c \le 100)\) representing the fee per truck when 1, 2, or 3 trucks are parked, respectively.
  2. The next three lines each contain two integers \(s\) and \(e\) \( (1 \le s < e \le 100)\) representing the start and end time (in minutes) for one of the trucks.

Note: A truck parked from time \(s\) to \(e\) is charged for each minute \(t\) where \(s \le t < e\).

outputFormat

Output a single integer representing the total fee Luka must pay for parking his trucks.

sample

5 3 1
1 6
3 5
2 8
33