CodeForces - 10A_模拟

本文探讨了一台电脑在不同工作状态下的能耗问题,通过分析三种模式下的功率消耗,提出了一个计算总能耗的算法。该算法考虑了正常模式、屏幕保护模式和睡眠模式的切换,以及用户在各模式间的交互行为。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 n, P1, P2, P3, T1, T2 (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 ≤ 1440, ri < 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.

Examples
Input

1 3 2 1 5 10
0 10

Output

30

Input

2 8 4 2 5 10
20 30
50 100

Output

570

题目大意:一台电脑有三种工作状态,每个工作状态有不同的耗电功率,求耗电值。


这题挺考察分类细节的,一个地方错了就过不了。
inline int f(int x, int l, int r)
{
    return x * (r - l);
}
int main()
{
    int n, p1, p2, p3, t1, t2;
    cin >> n >> p1 >> p2 >> p3 >> t1 >> t2;
    int ans = 0;
    int last = -1;
    while (n--)
    {
        int a, b;
        cin >> a >> b;
        ans += f(p1, a, b);
        if (last != -1)
            if (a - last <= t1)
            {
                ans += f(p1, last, a);
            }
            else
            {
                ans += f(p1, last, last + t1);
                if (a - last - t1 <= t2)
                {
                    ans += f(p2, last + t1, a);
                }
                else
                {
                    ans += f(p2, last + t1, last + t1 + t2);
                    ans += f(p3, last + t1 + t2, a);
                }
            }
        last = b;
    }
    cout << ans << endl;
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hesorchen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值