博客
关于我
CodeForces - 10A_模拟
阅读量:136 次
发布时间:2019-02-28

本文共 2279 字,大约阅读时间需要 7 分钟。

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 100 10

Output

30

Input

2 8 4 2 5 1020 3050 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;}

转载地址:http://jeod.baihongyu.com/

你可能感兴趣的文章
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>
mysql 死锁(先delete 后insert)日志分析
查看>>
MySQL 死锁了,怎么办?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 深度分页性能急剧下降,该如何优化?
查看>>
MySQL 添加列,修改列,删除列
查看>>
mysql 添加索引
查看>>
MySQL 添加索引,删除索引及其用法
查看>>
mysql 状态检查,备份,修复
查看>>