問題一覧 > 通常問題

No.1690 Power Grid

レベル : / AI推定難易度 : 1450 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 133
作問者 : ansain / テスター : LayCurse ygussany
お気に入りにしたユーザー ProblemId : 6622 / 自分の提出
問題文最終更新日: 2021-09-24 23:04:19
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 315 (順位表) の他の問題:

Problem Statement

The Kingdom of yukicoder has $N$ cities, numbered from city $1$ to city $N$, and $M$ roads.
The population of city $i\ (1 \le i \le N)$ is $A_i$. Road $i\ (1 \le i \le M)$ bidirectionally connects cities $X_i$ and $Y_i$, and its length is $Z_i$.
Between any $2$ cities of the kingdom, it is possible to travel in both directions by passing through some roads.

King ansain has decided to build power plants in $K$ cities, one after another.
Building the $1$st power plant in city $i$ costs $A_i$.
For the $2$nd and subsequent power plants, building one in city $i$ costs, in addition to $A_i$, the distance from city $i$ to the nearest city with an already built power plant.
Here, the distance between cities $i,j$ is the minimum total length of the roads passed through when traveling from city $i$ to city $j$.

Find the minimum cost required to build power plants in $K$ cities.

Input

$N\ M\ K$
$A_1$ $A_2$ $\dots$ $A_N$
$X_1$ $Y_1$ $Z_1$
$X_2$ $Y_2$ $Z_2$
$\vdots$
$X_M$ $Y_M$ $Z_M$

  • $1 \le N \le 18$
  • $N-1 \le M \le N(N-1)/2$
  • $1 \le K \le N$
  • $1 \le A_i \le10^9$
  • $1 \le X_i < Y_i \le N$
  • If $i \neq j $, then $(X_i,Y_i) \neq (X_j,Y_j)$
  • $1 \le Z_i \le 10^9$
  • All input values are integers
  • It is guaranteed that between any $2$ cities of the kingdom, it is possible to travel in both directions by passing through some roads
  • Output

    Output the minimum cost required to build power plants in $K$ cities. Print a newline at the end.

    Sample

    Sample 1
    Input
    3 2 2
    3 5 8
    1 2 9
    2 3 2
    Output
    15

    One example of an optimal way to build the power plants is as follows.

  • Build the $1$st one in city $2$. This costs $5$.
  • Build the $2$nd one in city $3$. This costs $8$ plus $2$, the distance from city $3$ to city $2$.
  • The total cost is $15$.

    Sample 2
    Input
    4 3 3
    10000 1 1 1
    1 2 1
    1 3 2 
    1 4 1
    Output
    8

    One example of an optimal way to build the power plants is as follows.

  • Build the $1$st one in city $2$. This costs $1$.
  • Build the $2$nd one in city $3$. This costs $1$ plus $3$, the distance from city $3$ to city $2$.
  • Build the $3$rd one in city $4$. This costs $1$ plus $2$, the distance to city $2$, which is the closest to city $4$ among cities $2,3$.
  • The total cost is $8$.

    Sample 3
    Input
    10 10 1
    1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000
    1 2 1
    2 3 10
    3 4 100
    4 5 1000
    5 6 10000
    6 7 100000
    7 8 1000000
    8 9 10000000
    9 10 100000000
    1 10 1000000000
    Output
    1

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。