【codeforces #10 】
来源:互联网 发布:睿医人工智能研究中心 编辑:程序博客网 时间:2024/04/28 17:14
A. Power Consumption Calculation
time limit per test
1 second
memory limit per test
256 megabytes
inputstandard 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 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 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个时间段,时间段内连续点击鼠标或键盘。求最后消耗的总功率。
解题:就一道简单的数学题;直接上代码:
code:
#include <iostream>#include <algorithm>#include <cstdio>#include <string.h>using namespace std;struct node{ int l,r;}a[102];int main(){ int n,p1,p2,p3,t1,t2; while(scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2)!=EOF) { int tp1=0,tp2=0,tp3=0; for(int i=0;i<n;i++) { scanf("%d%d",&a[i].l,&a[i].r); } if(n==1) printf("%d\n",(a[0].r-a[0].l)*p1); else { tp1=a[0].r-a[0].l; for(int i=1;i<n;i++) { tp1+=(a[i].r-a[i].l); if((a[i].l-a[i-1].r)<=t1) tp1+=(a[i].l-a[i-1].r); else if((a[i].l-a[i-1].r)<=(t1+t2)) { tp1+=t1; tp2+=(a[i].l-a[i-1].r-t1); } else { tp1+=t1; tp2+=t2; tp3+=(a[i].l-a[i-1].r-t1-t2); } } printf("%d\n",tp1*p1+tp2*p2+tp3*p3); } } return 0;}
0 0
- 【codeforces #10 】
- Codeforces Beta Round #10
- Educational Codeforces Round 10
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- android 同时运行两个ecplise android 项目
- Ant path 匹配原则
- 物联网之智能家居
- ACL访问控制列表
- SPRING MVC3.2案例讲解-请求重定向与请求转发
- 【codeforces #10 】
- 解决mysql"Access denied for user'root'@'IP地址'"问题
- ADF BC bc4j.xcfg专贴
- 数据结构——算法之(043)(c++各种排序算法实现)
- NYOJ 353 3D dungeon(三维数组BFS)
- const in C and C++
- 软件开发-人员流动
- 组播路由协议原理
- Linux sftp 的用法