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. Project Euler:Problem 88 Product-sum numbers

    A natural number, N, that can be written as the sum and product of a given set of at least two natur ...

  2. linux中设置TAB键的宽度

    对于编程的人员来说,常常须要排版代码,这时候就须要TAB键,但TAB键的宽度太大,非常有可能代码太长,延伸到下一行,这个时候你就须要设置TAB键的宽度了. linux下设置TAB键的宽度,做法例如以下 ...

  3. poj 2528 Mayor&#39;s posters 【线段树 + 离散化】

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 50643   Accepted: 14675 ...

  4. BroadcastReceiver类

    java.lang.Object    ↳ android.content.BroadcastReceiver 已知直接子类 AppWidgetProvider DeviceAdminReceiver ...

  5. 2015.03.16,外语,读书笔记-《Word Power Made Easy》 00 “如何最大限度的利用本书”学习笔记

    备注:蓝色表明是自己学习或笔记的部分,红色表明特别的地方,例如自己不理解或需要重点关注的地方.加粗单词表明是要加入生词库学习的词语.单词后面括号中的蓝色部分,是单词的解释和音标. 1.this is ...

  6. Linux下安装intellij idea

    1.下载 http://www.jetbrains.com/idea/download/#section=linux 我下载的是不带jdk的版本 2.放入opt目录中 3.解压到usr下面的intel ...

  7. qq邮箱的SMTP服务器是什么

    qq邮箱的SMTP服务器是什么 QQ邮箱POP3 和 SMTP 服务器地址设置如下:POP3服务器地址为“pop.qq.com”,SMTP服务器地址为“smtp.qq.com”注:1.SMTP服务器需 ...

  8. poj--3678--Katu Puzzle(2-sat 建模)

    Katu Puzzle Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit S ...

  9. AVL数

    平衡二叉树(AVL树) AVL树是一种二叉搜索树,并且每个节点的左右子树高度之差最多为1.AVL树是第一个在最坏的情况下保证以O(logn)的时间进行搜索,插入和删除操作的数据结构,AVL树能在对数时 ...

  10. js面向对象概念解析

    ECMAScript有两种开发模式: 1.函数式(过程化) 2.面向对象(OOP). 面向对象的语言有一个标志,那就是类的概念,而通过类可以创建任意多个具有相同属性和方法的对象.但是,ECMAScri ...