Logo
(追記) (追記ここまで)

33001번 - Omnes Viae Yokohamam Ducunt? 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB55444381.132%

문제

“Omnes viae Romam ducunt” is an old Latin proverb meaning “all roads lead to Rome.” It is still desirable to have access to the capital from all the regions of a country.

The Kingdom of Kanagawa has a number of cities, including the capital city, Yokohama. The Ministry of Transport of the Kingdom is now planning to construct a highway network, connecting all those cities.

There are a number of candidate highway segments, each of which directly connects two cities. A highway network is a set of highway segments chosen from the candidates. The following are required for the highway network.

  • All the cities should be connected via highway segments in the network, directly or indirectly.
  • To save the budget, the minimum number of segments should be chosen. In other words, the highway network should not be redundant; the path connecting any pair of cities should be unique.

The highway network should be made resistant to natural disasters, with the limited budget. The emphasis is placed on accessibility to and from the capital city, Yokohama. As the network is planned to be non-redundant, when one segment becomes unavailable due to a natural disaster, some of the cities become inaccessible from Yokohama.

We want to minimize the total risk severity, defined as follows.

The cities in the Kingdom have different populations and economic scales, based on which, the cities are assigned certain significance values. Given a highway network, the damage suffered from a natural disaster on a single segment in the network is estimated by the sum of the significance values of such cities made inaccessible from Yokohama.

Vulnerabilities to natural disasters are assessed for all the candidate segments. The risk severity of a segment is calculated as the product of its estimated damage and vulnerability. The total risk severity of the network is estimated as the sum of the risk severities of all the segments in the network.

Your task is to determine the minimum total risk severity by appropriately designing the highway network.

입력

The input consists of a single test case of the following format.

$n$ $m$

$p_1$ $\cdots$ $p_n$

$u_1$ $v_1$ $q_1$

$\vdots$

$u_m$ $v_m$ $q_m$

The first two integers $n$ and $m$ (2ドル ≤ n ≤ 10^5,ドル 1ドル ≤ m ≤ 3 \times 10^5$) describe the numbers of cities and highway segment candidates, respectively. The cities are numbered from 1ドル$ to $n,ドル with Yokohama numbered 1ドル$. The second line contains $n$ integers $p_1, \dots , p_n,ドル where each $p_i$ (1ドル ≤ p_i ≤ 1000$) represents the significance value assigned to the city numbered $i$.

The following $m$ lines describe the candidate highway segments. The $j$-th line of them contains three integers $u_j,ドル $v_j,ドル and $q_j$ (1ドル ≤ u_j < v_j ≤ n,ドル 1ドル ≤ q_j ≤ 10^6$), meaning that the segment candidate connecting cities numbered $u_j$ and $v_j$ has the vulnerability $q_j$. Each pair $(u_j , v_j )$ appears at most once in the input.

It is guaranteed that one or more highway networks that connect all the cities can be designed using some of these segments.

출력

Output a line containing the minimum possible total risk severity.

제한

예제 입력 1

3 3
1 2 3
1 2 2
2 3 3
1 3 4

예제 출력 1

16

예제 입력 2

5 7
2 6 7 7 10
1 5 8
1 4 6
3 4 9
2 3 6
2 4 7
1 3 4
4 5 4

예제 출력 2

210

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > 2024 ICPC Asia Yokohama Regional Contest C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /