TouchStone
  请登录后使用
登录 注册
 系统首页  练习题库  考试列表  判题结果  信息发布  解题排行
  • 首页
  • 题库
  • P4108
  • 题目
  • P4108Freight
    限制 : 时间限制 : 30000 MS   空间限制 : 165536 KB
    问题描述

    The train stations in Upper Bytown and Lower Bytown are connected with a single track rail link. It takes the train  minutes to travel between them in either direction. However, the trains departing a station have to be spaced at least one minute apart. Moreover, at all times, all the trains on the rail link have to go in the same direction.

    According to the timetable at our disposal,  cargo trains destined for Lower Bytown are to pass through the Upper Bytown. They are to be loaded with goods in Lower Bytown and then return to Upper Bytown. For simplicity, we assume that loading the goods on the train takes virtually no time.

    We are to determine the minimum possible time of the last train returning to Upper Bytown.

    输入格式

    The first line of the standard input contains two integers  (), separated by a single space, that specify the number of trains and the one-way travel time respectively. The second line contains  integers  (), separated by a single space, that specify the arrival times of successive trains at the Upper Bytown station.

    In test worth  of the total score,  holds. Moreover, in their subset worth  of the total score,  holds in addition.

    输出格式

    Your program should print out a single line with a single integer to the standard output: the minimum possible time of the last train returning to Upper Bytown.

    样例输入

    3 4
    1 8 11

    样例输出

    20

    提示

    Explanation: To attain the minimum time, the trains can depart from Upper Bytown at times , and , and from Lower Bytown at times , and .


    来源  poi2014 bzoj3830