zoukankan      html  css  js  c++  java
  • HDU 4011 Working in Beijing

    Working in Beijing

    Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
    Total Submission(s): 659    Accepted Submission(s): 333


    Problem Description
    Mr. M is an undergraduate student of FDU. He finds an intern position in Beijing, so that he cannot attend all the college activities. But in some conditions, he must come back to Shanghai on certain date. We can assume the important activities that Mr. M must attend are occupy a whole day. Mr. M must take flight to Shanghai before that day and leave after that day. On the other hand, Mr. M is absent in Beijing and he will lose his salary for his absent.
    Sometimes the cost of flight is much higher than the loss of salary, so to save the cost on the travel, Mr. M can stay in Shanghai to wait for another important date before he back to Beijing.
    Now, Mr. M knows all of the important date in the next year. Help him schedule his travel to optimize the cost.
     

    Input
    The input contains several test cases. The first line of single integer indicates the number of test cases.
      For each test case, the first line contains three integers: n, a and b, denoting the number of important events, the cost of a single flight from Beijing to Shanghai or Shanghai to Beijing and the salary for a single day stay in Beijing. (1 <= n <= 100000, 1 <= a <= 1000000000, 1 <= b <=100)
      Next line contains n integers ti, denoting the time of the important events. You can assume the ti are in increasing order and they are different from each other. (0 <= ti <= 10000000)
     

    Output
    For each test case, output a single integer indicating the minimum cost for this year.
     

    Sample Input
    2 1 10 10 5 5 10 2 5 10 15 65 70
     

    Sample Output
    Case #1: 30 Case #2: 74
     

    Source
     

    Recommend
    lcy
     
     
    #include<stdio.h>
    int main()
    {
    long long res;
    int n,a,b;
    int t1,t2;
    int i,T;
    int iCase=0;
    scanf("%d",&T);
    while(T--)
    {
    iCase++;
    scanf("%d%d%d",&n,&a,&b);
    res=a+b;
    scanf("%d",&t1);
    for(i=1;i<n;i++)
    {
    scanf("%d",&t2);
    if((t2-t1-1)*b>2*a) res+=2*a+b;
    else res+=b*(t2-t1);
    t1=t2;
    }
    res+=a;
    printf("Case #%d: %I64d\n",iCase,res);
    }
    return 0;
    }
  • 相关阅读:
    iTOP-4412开发板-串口基础知识和测试方法
    迅为i.MX6ULL终结者开发板-能想到的功能它都有
    Android4.4.2 源码编译-iMX6Q/D核心板-非设备树源码
    如何让Dev支持c++11特性
    2019年第十届蓝桥杯【C++省赛B组】
    upper_bound()和low_bound函数的基本使用和理解(转载,已获博主授权)
    C++的bitset(位操作使用),转载
    2018年第九届蓝桥杯【C++省赛B组】(未完)
    2013蓝桥杯预赛C/C++本科B组
    信用卡号验证
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2198939.html
Copyright © 2011-2022 走看看