https://acs.jxnu.edu.cn/external/gym/doc/GYM100004A.doc
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 Specification
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.)
Sample Input
2
1
3
4
0 1 1
0 2 2
Output Specification
Output the minimum time it will take to deliver all the papers and get to class.
Output for Sample Input
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
Hanson Wang
中文翻译:
作为一个贫穷、学费负担沉重的学生,你已经决定做一份兼职工作,做个报童/女报童。
您刚刚收到了您的纸张路线:一组地址(方便地标记为1到N)方便地,在您的地区只有N条道路连接地址,它们每一个都需要一个已知的时间来遍历,此外,你还预先计算了从每个地址到滑铁卢校园所需的时间,包括报社(通过骑自行车、乘公共汽车或搭顺风车)。你多久才能完成送报工作,坐在学校的座位上?
首先,将有一个整数N(地址数,1≤N≤100,000),接下来将有N+1行,每一行都带有整数ci(从i=0, 0 ≤ ci ≤ 1,000,000,000)整数a,b,c(0≤a,b≤N,a=b,0≤c≤1,000)。这两条线描述了位置a到b之间的一条道路,需要c分钟才能通过。保证您能够到达所有地址。(请记住,位置0是报社)。
输入:
2
1
3
4
0 1 1
0 22
输出:
输出所需的最短时间,以交付所有论文并到达类。
供样本输入。
7
实际上,最好是访问所有的地址,回到办公室,然后从那里上学,
例如:0->1->0->2->0->学校=1+1+2+2+1=7