codeforce 10A

http://vjudge.net/contest/view.action?cid=47807#problem/A

Description

Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P2 watt per minute. Finally, after T2 minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P3 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 time periods [l1, r1], [l2, r2], ..., [ln, rn]. 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].

Input

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

Output

Output the answer to the problem.

Sample Input

Input
1 3 2 1 5 10
0 10
Output
30
Input
2 8 4 2 5 10
20 30
50 100
Output
570
题目大意:电脑在三个不同的阶段每分钟的耗电量为p1,p2,p3,从最后一次碰鼠标或键盘起t1时间内耗电速率和碰键盘或鼠标时相同为p1,而后的t2时间内耗电为p2,之后耗电为p3.已知触碰电脑的时间段,求总耗电量。

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int a[200][3];
int p[200][3];
int main()
{
    int n,p1,p2,p3,t1,t2;
    while(~scanf("%d",&n))
    {
        scanf("%d%d%d%d%d",&p1,&p2,&p3,&t1,&t2);
        int sum=0;
        for(int i=0;i<n;i++)
        {
           scanf("%d%d",&a[i][0],&a[i][1]);
           sum+=(a[i][1]-a[i][0])*p1;
        }
        for(int i=0;i<n-1;i++)
        {
            p[i][0]=a[i][1];
            p[i][1]=a[i+1][0];
            if(p[i][1]-p[i][0]<=t1)
                sum+=(p[i][1]-p[i][0])*p1;
            else if(p[i][1]-p[i][0]<=t1+t2)
                sum+=t1*p1+(p[i][1]-p[i][0]-t1)*p2;
            else
                sum+=t1*p1+t2*p2+(p[i][1]-p[i][0]-t1-t2)*p3;
        }
        printf("%d\n",sum);
    }
    return 0;
}


你可能感兴趣的:(codeforce 10A)