#P3171. [CQOI2015] 网络吞吐量

    ID: 2220 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015重庆各省省选网络流最短路最大流

[CQOI2015] 网络吞吐量

Description

Now, given the connectivity between routers in a computer network and the maximum throughput of each router (i.e., the number of packets it can forward per second), with routers numbered from 11 to nn, assume all packets are forwarded strictly along shortest paths. Compute the maximum throughput from router 11 to router nn. Ignore the time overhead of forwarding and transmission, and do not consider link bandwidth limits, i.e., assume packets can traverse the network instantaneously. Routers 11 and nn serve as the source and destination, and their own throughputs are not considered. There is also no link that directly connects 11 and nn.

Input Format

The first line contains two integers separated by a space, representing the number of routers nn and the number of links mm.

Lines 22 to (m+1)(m + 1) each contain three integers u,v,wu, v, w, indicating there is an undirected link connecting routers uu and vv with distance ww.

Lines (m+2)(m + 2) to (n+m+1)(n + m + 1) each contain one integer. The integer on line (i+m+1)(i + m + 1) represents the throughput cic_i of router ii.

Output Format

Output a single line containing one integer, representing the maximum throughput of the network.

7 10
1 2 2
1 5 2
2 4 1
2 3 3
3 7 1
4 5 4
4 3 1
4 6 1
5 6 2
6 7 1
1
100
20
50
20
60
1
70

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n5001 \leq n \leq 500, 1m1051 \leq m \leq 10^5, and 1w,ci1091 \leq w, c_i \leq 10^9.

Translated by ChatGPT 5