問題一覧 > 通常問題

No.2549 Paint Eggs

レベル : / AI推定難易度 : 1225 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 65
作問者 : dyktr_06 / テスター : sepa38 InTheBloom Seed57_cash ryota2357
お気に入りにしたユーザー ProblemId : 10255 / 自分の提出
問題文最終更新日: 2023-11-22 09:28:49
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
MMA Contest 017 (順位表) の他の問題:

Problem Statement

$N$ eggs are lined up in a row.

Each egg is painted in one of the colors represented by integers from $1$ to $M$, and the $i \: (1 \leq i \leq N)$-th egg from the left is painted in color $C_i$.

You may choose any egg and repaint it any number of times, and repainting an egg to color $j \: (1 \leq j \leq M)$ costs $A_j$.

Find the minimum cost required to make the colors of some $K$ consecutive eggs all the same.


Constraints

  • $1 \leq K \leq N \leq 2 \times 10^{5}$
  • $1 \leq M \leq 2 \times 10^{5}$
  • $1 \leq C_i \leq M$
  • $1 \leq A_j \leq 10^{9}$
  • All input values are integers.

Input

The input is given from standard input in the following format.

$N$ $M$ $K$ 
$C_1$ $C_2$ ... $C_N$ 
$A_1$ $A_2$ ... $A_M$ 

Output

Output the answer to the problem on one line.

Sample

Sample 1
Input
5 3 3
1 2 1 3 2
10 10 10
Output
10

If you repaint the $2$-nd egg to color $1$, the $1$-st through $3$-rd eggs will have the same color, which achieves the goal.

The cost is $10$, and it cannot be made any smaller.

Sample 2
Input
5 3 3
1 1 1 1 1
10 10 10
Output
0

The goal may already be achieved from the start.

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