n,p1,p2,p3,t1,t2=map(int,input().split())
def interval(x):
if x<=t1:
return x*p1
elif x<=t1+t2:
return x*p2+t1*(p1-p2)
else:
return x*p3+t2*(p2-p3)+t1*(p1-p3)
e1,e2=0,0
for i in range(n):
a,b=map(int,input().split())
e1+=(b-a)*p1
if i>0:
e2+=interval(a-b0)
b0=b
print(e1+e2)
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n,p1,p2,p3,t1,t2,sum=0;
cin>>n>>p1>>p2>>p3>>t1>>t2;
int l[n],r[n];
for(int i=0;i<n;i++)
{
cin>>l[i]>>r[i];
sum=sum+(r[i]-l[i])*p1;
}
for(int i=0;i<n-1;i++)
{
if(l[i+1]-r[i]<=t1)
sum=sum+(l[i+1]-r[i])*p1;
else if(t1<l[i+1]-r[i] && l[i+1]-r[i]<=t1+t2)
sum= sum+ t1*p1 +(-r[i]+l[i+1]-t1)*p2;
else if(t1+t2<-r[i]+l[i+1])
sum=sum+t1*p1+t2*p2+(-r[i]+l[i+1]-t1-t2)*p3;
}
cout<<sum;
}
1585B - Array Eversion | 1661C - Water the Trees |
1459A - Red-Blue Shuffle | 1661B - Getting Zero |
1661A - Array Balancing | 1649B - Game of Ball Passing |
572A - Arrays | 1455A - Strange Functions |
1566B - MIN-MEX Cut | 678C - Joty and Chocolate |
1352E - Special Elements | 1520E - Arranging The Sheep |
1157E - Minimum Array | 1661D - Progressions Covering |
262A - Roma and Lucky Numbers | 1634B - Fortune Telling |
1358A - Park Lighting | 253C - Text Editor |
365B - The Fibonacci Segment | 75A - Life Without Zeros |
1519A - Red and Blue Beans | 466A - Cheap Travel |
659E - New Reform | 1385B - Restore the Permutation by Merger |
706A - Beru-taxi | 686A - Free Ice Cream |
1358D - The Best Vacation | 1620B - Triangles on a Rectangle |
999C - Alphabetic Removals | 1634C - OKEA |