A. Power Consumption Calculation
2016-04-21 19:02
751 查看
A. Power Consumption Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTom 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].InputThe 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.OutputOutput the answer to the problem.Sample test(s)input
1 3 2 1 5 10 0 10output
30input
2 8 4 2 5 10 20 30 50 100output
570一个分段函数的求解 模拟
/* *********************************************** Author : Created Time :2015/6/2 16:01:09 File Name :2.cpp ************************************************ */ #include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <iomanip> #include <list> #include <deque> #include <stack> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 1<<30 #define maxn 10000+10 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; bool cmp(int a,int b){ return a>b; } int s[maxn]; int sum; int n,p1,p2,p3,t1,t2; int getsum(int t){ if(t<=t1)return p1*t; else if(t>t1&&t<=t1+t2)return p2*(t-t1)+t1*p1; else if(t>t1+t2)return p3*(t-t2-t1)+p2*t2+p1*t1; } int main() { #ifndef ONLINE_JUDGE //freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); while(cin>>n>>p1>>p2>>p3>>t1>>t2){ int a,b; int j=0; int t; sum=0; for(int i=1;i<=n;i++){ cin>>a>>b; if(i==1)t=a; sum+=b-a; s[j++]=a-t; t=b; } sum*=p1; for(int i=1;i<j;i++){ sum+=getsum(s[i]); //cout<<"//"<<getsum(s[i])<<endl; } cout<<sum<<endl; } return 0; }
相关文章推荐
- 【问题解决】FragmentTabHost 底部菜单栏,切换Frgment时重新加载问题
- 使用Ajax实现异步用户名验证
- hiho#1139 : 二分·二分答案
- A. Die Roll
- 错排公式
- Crontab配置及使用总结
- Oracle内置表二
- CalendarView功能与用法(日历视图)
- 报名|「OneAPM x DaoCloud」技术公开课:Docker性能监控!
- Friday the Thirteenth
- DINIC 模板
- Greedy Gift Givers
- Activity之封装intent
- 2015年06月17日
- HDU 1215七夕节
- Codeforces Beta Round #8
- Codeforces Beta Round #7
- Codeforces Beta Round #6 (Div. 2 Only)
- HDU 1878 欧拉回路
- Codeforces Beta Round #5