Codeforces 10A-Power Consumption Calculation(模拟)
1 second
256 megabytes
standard input
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].
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 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 the answer to the problem.
1 3 2 1 5 10
0 10
30
2 8 4 2 5 10
20 30
50 100
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(模拟)的更多相关文章
- Codeforces Beta Round #10 A. Power Consumption Calculation 水题
A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...
- A. Power Consumption Calculation
http://codeforces.com/problemset/problem/10/A 题很简单,就是题意难懂啊... #include <stdio.h> #include < ...
- Power consumption comparison
Here is my draft evaluation when old MCU replacement for power consumption, the comparsion betwween ...
- 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 ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- 電池的標稱電壓 與 power consumption 量測
電池標稱電壓 定義如下圖, 以25度為例,20度再往上點, 4V 放一下電就往下掉, 3V 放一下電就往下掉, 假設 3.8V 是擁有最多 capacity 可以 discharge 的電壓,放電放了 ...
- 手機 停充的種類 與 量測 power consumption 功率 使用 bq25896 bq25890
Precondition : 配有 power path 功能的 BQ2589 手機. 接上 pc usb port. Origin : 今天有同事問我, 手機是否可以在接上 pc usb port ...
- [CodeForces - 1225D]Power Products 【数论】 【分解质因数】
[CodeForces - 1225D]Power Products [数论] [分解质因数] 标签:题解 codeforces题解 数论 题目描述 Time limit 2000 ms Memory ...
- [Codeforces 1246B] Power Products (STL+分解质因数)
[Codeforces 1246B] Power Products (STL+分解质因数) 题面 给出一个长度为\(n\)的序列\(a_i\)和常数k,求有多少个数对\((i,j)\)满足\(a_i ...
随机推荐
- HDFS学习笔记(1)初探HDFS
Hadoop分布式文件系统(Hadoop Distributed File System, HDFS) 分布式文件系统是一种同意文件通过网络在多台主机上分享的文件系统.可让多机器上的多用户分享文件和存 ...
- IOS之UITableView——怎样刷新父页面的Cell
问题:评论数同步 在社交相关的项目中常常有这种主页面,主列表的Cell中有赞数.评论数,详情页顶部也是相同的一个Cell,下部有评论列表,评论添加或降低.详情页的评论数随之改变,返回主列表,主列表的相 ...
- python 从bulkblacklist信誉查询网站提交查询
import urllib import urllib2 #import webbrowser import re import socket def is_domain_in_black_list( ...
- vue-quill-editor 禁止编辑
每天学习一点点,知识财富涨点点 因为权限问题需要对富文本vue-quill-editor进行禁止编辑,因为也不是专业前端,处理起问题来还是只有看文档和百度,发现对这个提问不是很多,可能很多大牛都不会出 ...
- FMDB条件更新
更新操作返回一个BOOL值,YES表示操作成功,NO表示执行过程遇到错误,可以通过-lastErrorMessage和-lastErrorCode查看错误信息.使用executeUpdate:方法执行 ...
- 绘图中的drawRect
rect参数:代表的是当前view的bounds 1 为什么要在drawRect方法里面写绘图代码 因为只有在这个方法中才能获取到当前view相关的图形上下文对象 有了这个图形上写文对象后才能进行绘图 ...
- 利用jqueryzoom实现图片放大镜效果
在你的页面中包含 jqzoom.css <link rel="stylesheet" href="your_path/jqzoom.css" type=& ...
- 性能优化实战-join与where条件执行顺序
昨天经历了一场非常痛苦的性能调优过程,但是收获也是刻骨铭心的,感觉对sql引擎的原理有了进一步认识. 问题起源于测试人员测一个多条件检索的性能时,发现按某个条件查询会特别慢.对应的sql语句简化为: ...
- JAVA在线观看视频教程完整版
今天给大家介绍一下JAVA在线观看视频教程完整版,我们知道Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由Sun Microsystems公司于1995年5月推出的Java程序设计语 ...
- 第一次接触Arduino
1.百度百科: Arduino包含两个主要的部分:硬件部分是可以用来做电路连接的Arduino电路板:另外一个则是 Arduino IDE,你的计算机中的程序开发环境.你只要在IDE中编写程序代码,将 ...