A. Power Consumption Calculation

题目连接:

http://www.codeforces.com/contest/10/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 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.

Sample Input

1 3 2 1 5 10

0 10

Sample Output

30

Hint

题意

有一台电脑,在活跃状态下,每秒钟耗能p1,在没人碰之后的t1秒后,进入休息状态,每秒钟耗能p2,如果再有t3秒没人碰的话,就会进入睡眠状态,每秒钟耗能p3

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

题解:

数据范围太小,直接暴力就好了……

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
int n,p1,p2,p3,t1,t2;
pair<int,int> Q[maxn];
int p[3000];
int main()
{
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
for(int i=1;i<=n;i++)scanf("%d%d",&Q[i].first,&Q[i].second);
for(int i=1;i<=n;i++)for(int j=Q[i].first;j<=Q[i].second;j++)
p[j]=1;
long long ans = 0;
int type=0,now=0;
for(int i=Q[1].first;i<Q[n].second;i++)
{
if(p[i]==1)now=0,ans+=p1;
else if(now>=t1+t2)ans+=p3;
else if(now>=t1)ans+=p2;
else ans+=p1;
now++;
}
cout<<ans<<endl;
}

最新文章

  1. 几个最常用的用来代替Div的HTML5元素
  2. 【Android】Fragment懒加载和ViewPager的坑
  3. ListView的使用-模拟微博随便看看栏目【执行与优化】
  4. java-----基本数据类型包装类
  5. 手机3D游戏开发:自定义Joystick的相关设置和脚本源码
  6. Android中通过代码获取arrays.xml文件中的数据
  7. UILabel的讲解
  8. 设置某个类使用或者禁用ARC
  9. 3.3-1933 problem A
  10. java中事件驱动
  11. springboot + mybatis +druid
  12. Linux 变量的使用
  13. cocos2d-x2.2.3 Layer分析
  14. LintCode——Pour Water
  15. App Store 加急审核解析
  16. SQL学习笔记之简易ORM
  17. 1006 Sign In and Sign Out (25)(25 分)思路:普通的时间比较题。。。
  18. 03 Oracle分区表
  19. discuzX3.2 X3.4网站漏洞修复 SQL注入与请求伪造攻击利用与修复
  20. C++11新标准:constexpr关键字

热门文章

  1. php常用代码段
  2. python之supervisor进程管理工具
  3. malloc原理和内存碎片【转】
  4. C#技术分享【PDF转换成图片——11种方案】
  5. go语言入门(一)
  6. MemCached缓存操作
  7. Denoise Autoencoder简单理解
  8. Codefroces 735D Taxes(哥德巴赫猜想)
  9. 向SD卡写入树莓派的操作系统
  10. markdown 测试代码