21295_PaperRoute

2022-5-16 18:19| 发布者: Hocassian| 查看: 36| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89505112339200-Problem List-采集的数据-后羿采集器.html

Pro.ID

21295

Title

Paper Route

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21295

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    As a poor, tuition-ridden student, you've decided to take up a part time job as a paperboy/papergirl.

    You've just been handed your paper route: a set of addresses (conveniently labelled 1 to N).

    Every morning, you start at the newspaper office (which happens to be address number 0). You have to plan a route to deliver a newspaper to every address - and you also want to get to class right after you're done.Conveniently, there are only N roads in your area connecting the addresses, and each of them takes a known time to traverse.

    Also, you've precalculated the time it takes to get to Waterloo campus from each address, including the newspaper office (through some combination of biking, busing, or hitching a ride).How soon can you be done delivering papers and be in your seat at school?

    输入

    First, there will be a single integer N (the number of addresses, 1 ≤ N ≤ 100,000).

    Next, there will be N+1 lines, each with an integer ci (starting with i = 0, 0 ≤ ci ≤ 1,000,000,000), the time it takes to get from location i to campus.

    Finally, the input will contain N lines, each with three integers a, b, c (0 ≤ a, b ≤ N, a ≠ b, 0 ≤ c ≤ 1,000). Each of these lines describes a road between locations a and b taking c minutes to traverse.

    It is guaranteed that you will be able to reach all the addresses. (Remember that location 0 is the newspaper office.)

    输出

    Description

    As a poor, tuition-ridden student, you've decided to take up a part time job as a paperboy/papergirl.

    You've just been handed your paper route: a set of addresses (conveniently labelled 1 to N).

    Every morning, you start at the newspaper office (which happens to be address number 0). You have to plan a route to deliver a newspaper to every address - and you also want to get to class right after you're done.Conveniently, there are only N roads in your area connecting the addresses, and each of them takes a known time to traverse.

    Also, you've precalculated the time it takes to get to Waterloo campus from each address, including the newspaper office (through some combination of biking, busing, or hitching a ride).How soon can you be done delivering papers and be in your seat at school?

    Input

    First, there will be a single integer N (the number of addresses, 1 ≤ N ≤ 100,000).

    Next, there will be N+1 lines, each with an integer ci (starting with i = 0, 0 ≤ ci ≤ 1,000,000,000), the time it takes to get from location i to campus.

    Finally, the input will contain N lines, each with three integers a, b, c (0 ≤ a, b ≤ N, a ≠ b, 0 ≤ c ≤ 1,000). Each of these lines describes a road between locations a and b taking c minutes to traverse.

    It is guaranteed that you will be able to reach all the addresses. (Remember that location 0 is the newspaper office.)

    Output

    Output the minimum time it will take to deliver all the papers and get to class.

    Sample Input

    2
    1
    3
    4
    0 1 1
    0 2 2

    Sample Output

    7

    Hint

    It's actually better to visit all the addresses, go back to the office, and get to school from there.
    An example route: 0 -> 1 -> 0 -> 2 -> 0 -> school = 1 + 1 + 2 + 2 + 1 = 7

    Source

    样例输入

    2
    1
    3
    4
    0 1 1
    0 2 2

    样例输出

    7

    提示

    It's actually better to visit all the addresses, go back to the office, and get to school from there.
    An example route: 0 -> 1 -> 0 -> 2 -> 0 -> school = 1 + 1 + 2 + 2 + 1 = 7


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部