| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 512 MB | 80 | 9 | 9 | 13.433% |
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