A. Power Consumption Calculation
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 nP1, P2, P3, T1, T2 (1 ≤ n ≤ 100, 0 ≤ P1, P2, P3 ≤ 100, 1 ≤ T1, T2 ≤ 60).
The following nlines 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 test(s)
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。假设没有使用电脑t1分钟后变成另外一种模式每分钟耗电p2,假设还是没有使用电脑t2分钟后变成第三种模式每分钟耗电p3。给定n个区间,每个区间是正常模式,每个区间的间隔是没有使用。问总的耗电是多少
思路:直接模拟就可以。
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
using namespace std;
#define LL long long
int main()
{
int n,p1,p2,p3,t1,t2,l[110],r[110];
while(cin>>n>>p1>>p2>>p3>>t1>>t2)
{
int ans=0;
for(int i=0;i<n;i++)
{
cin>>l[i]>>r[i];
ans+=(r[i]-l[i])*p1;
if(i>0)
{
if(l[i]-r[i-1]>t1)
{
ans+=t1*p1;
int t=l[i]-r[i-1]-t1;
if(t>t2)
{
ans+=t2*p2;
ans+=(t-t2)*p3;
}
else
ans+=t*p2;
}
else
ans+=(l[i]-r[i-1])*p1;
}
}
printf("%d\n",ans);
}
return 0;
}

Codeforces 10A-Power Consumption Calculation(模拟)的更多相关文章

  1. Codeforces Beta Round #10 A. Power Consumption Calculation 水题

    A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...

  2. A. Power Consumption Calculation

    http://codeforces.com/problemset/problem/10/A 题很简单,就是题意难懂啊... #include <stdio.h> #include < ...

  3. Power consumption comparison

    Here is my draft evaluation when old MCU replacement for power consumption, the comparsion betwween ...

  4. Low Power Consumption Design --- MCU Attention

    20161008 note : I have a PCB board called 'A' where a piece of STM8L052C6 and a piece of CC1101 are ...

  5. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  6. 電池的標稱電壓 與 power consumption 量測

    電池標稱電壓 定義如下圖, 以25度為例,20度再往上點, 4V 放一下電就往下掉, 3V 放一下電就往下掉, 假設 3.8V 是擁有最多 capacity 可以 discharge 的電壓,放電放了 ...

  7. 手機 停充的種類 與 量測 power consumption 功率 使用 bq25896 bq25890

    Precondition : 配有 power path 功能的 BQ2589 手機. 接上 pc usb port. Origin : 今天有同事問我, 手機是否可以在接上 pc usb port ...

  8. [CodeForces - 1225D]Power Products 【数论】 【分解质因数】

    [CodeForces - 1225D]Power Products [数论] [分解质因数] 标签:题解 codeforces题解 数论 题目描述 Time limit 2000 ms Memory ...

  9. [Codeforces 1246B] Power Products (STL+分解质因数)

    [Codeforces 1246B] Power Products (STL+分解质因数) 题面 给出一个长度为\(n\)的序列\(a_i\)和常数k,求有多少个数对\((i,j)\)满足\(a_i ...

随机推荐

  1. QTP自带订票实现循环执行,參数化和将异常提示信息输出

    做这个样例主要是为了积累一些较基础的知识,以便日后可參考学习 这个样例是一个订票的C/Sclient程序 一.业务需求: 1.实现异常和正常数据登录窗体,系统对数据进行校验 2.登录成功后.进行订票业 ...

  2. hdu3966_树链剖分

    近期在强化知识点深度.发现树链剖分不是非常会写了. 回想一下改动操作: 若两个点在同一条链上,则直接改动这段区间. 若不在同一条链上,改动深度较大的点到其链顶端的区间,同一时候将这个点变为他所在链顶端 ...

  3. Gzip压缩优化网站

    网站常使用GZIP压缩算法对网页内容进行压缩,然后传给浏览器,以减小数据传输量,提高响应速度.浏览器接收到GZIP压缩数据后会自动解压并正确显示.GZIP加速常用于解决网速慢的瓶颈. 压缩Filter ...

  4. 杂项-Java:Spring

    ylbtech-杂项-Java:Spring Spring是一个开放源代码的设计层面框架,他解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用.Spring是于200 ...

  5. 4.vim操作

    你想以最快的速度学习人类史上最好的文本编辑器VIM吗?你先得懂得如何在VIM幸存下来,然后一点一点地学习各种戏法. 我建议下面这四个步骤: 存活 感觉良好 觉得更好,更强,更快 使用VIM的超能力 当 ...

  6. init&initWithFrame&initWithCoder

    //当我们所写的程序里没用用Nib文件(XIB)时,用代码控制视图内容,需要调用initWithFrame去初始化 - (id)initWithFrame:(CGRect)frame { if (se ...

  7. BZOJ 3230 后缀数组+ST

    思路: 首先我们已经会了后缀数组求本质不同的子串个数 这道题跟那个差不多 首先我们可以知道按字典序排好的每个后缀之前包含多少本质不同的字串 就是sigma(n-sa[i]+1-ht[i]+bi[i-1 ...

  8. c#设计模式(1)

    本文摘取自吕震宇的博客园文章,版权归吕震宇仅供个人学习参考.转载请标明原作者吕震宇. 这学期开设设计模式课程,将课件放上来. 课本:<C#设计模式>,电子工业出版社,ISBN 7-5053 ...

  9. ASP.net 中 OutputCache 指令各个参数的作用

    使用@ OutputCache指令 使用@ OutputCache指令,能够实现对页面输出缓存的一般性需要.@ OutputCache指令在ASP.NET页或者页中包含的用户控件的头部声明.这种方式非 ...

  10. [原创]c语言中const与指针的用法

    最近一直在准备笔试,补补大一大二欠下的课.复习c语言时碰见这么个题:   1 2 3 4 5 int a=248, b=4; int const c=21; const int *d=&a;  ...