zoukankan      html  css  js  c++  java
  • Codeforces 10A-Power Consumption Calculation(模拟)

    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 nP1P2P3T1T2 (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 ≤ 1440ri < 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
    ",ans);
    	}
    	return 0;
    }
    


  • 相关阅读:
    5.21 CSS样式表练习
    5.20 c#验证码练习
    5.20 邮箱注册,及网页嵌套,知识点复习
    5.19 网页注册练习
    5.19练习标签及其 定义
    5.16 兔子生兔子,日期时间练习
    5.15 复习;共5题
    5.11 集合 与 特殊集合
    5.11 集合与特殊集合
    WinForm1
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/6913848.html
Copyright © 2011-2022 走看看