시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 67 | 7 | 7 | 10.769% |
There are $M$ boxes and $N$ balls. The balls are numbered $1$ through $N$, and the weight of the ball $i$ is $w_i$. You are also given a sequence $a_1, a_2, \ldots, a_K$. Each $a_j$ is an integer satisfying $1 \le a_j \le N$.
Initially, all the boxes are empty. For each $j = 1, 2, \ldots, K$ in this order, you have to perform the following operation:
Compute the minimum possible total cost of operations.
The first line contains three integers $M$, $N$ and $K$ ($1 \le M \le 10$, $1 \le N, K \le 10^4$).
The $i$-th of the next $N$ lines contains an integer $w_i$ ($1 \le w_i \le 10^4$).
The $j$-th of the next $K$ lines contains an integer $a_j$ ($1 \le a_j \le N$).
Print the minimum total cost.
3 3 6 10 20 30 1 2 3 1 2 3
60
2 3 6 10 20 30 1 2 3 1 2 3
80