#983. Power Consumption Calculation

Power Consumption Calculation

题面翻译

有一台电脑,在活跃状态下,每秒钟耗能 P1P1,在没人碰之后的 T1T1 秒后,进入休息状态,每秒钟耗能 P2P2,如果再有 T2T2 秒没人碰的话,就会进入睡眠状态,每秒钟耗能 P3P3

给你这个人碰电脑的区间时间,问你这台电脑的耗能是多少

题目描述

Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 P_{1} watt per minute. T1 T_{1} minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 P_{2} watt per minute. Finally, after T2 T_{2} minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 P_{3} watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n n time periods [l1,r1],[l2,r2],...,[ln,rn] [l_{1},r_{1}],[l_{2},r_{2}],...,[l_{n},r_{n}] . During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [l1,rn] [l_{1},r_{n}] .

输入格式

The first line contains 6 integer numbers n n , P1 P_{1} , P2 P_{2} , P3 P_{3} , T1 T_{1} , T2 T_{2} ( 1<=n<=100,0<=P1,P2,P3<=100,1<=T1,T2<=60 1<=n<=100,0<=P_{1},P_{2},P_{3}<=100,1<=T_{1},T_{2}<=60 ). The following n n lines contain description of Tom's work. Each i i -th of these lines contains two space-separated integers li l_{i} and ri r_{i} ( 0<=li<ri<=1440 0<=l_{i}<r_{i}<=1440 , ri<li+1 r_{i}<l_{i+1} for i<n i<n ), which stand for the start and the end of the i i -th period of work.

输出格式

Output the answer to the problem.

样例 #1

样例输入 #1

1 3 2 1 5 10
0 10

样例输出 #1

30

样例 #2

样例输入 #2

2 8 4 2 5 10
20 30
50 100

样例输出 #2

570