QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#7762. 数据库

الإحصائيات

给定长为 $ n $ 的序列 $ w_{1},w_{2},...,w_{n} $,有一个长为 $ m $ 的序列 $ a_{1},a_{2},...,a_{m} $,初始 $ \forall 1\le i\le m,a_{i}=0 $

给定 $ q $ 次请求,每次请求包含一个数 $ k $:

若 $ \exists 1\le i\le m,a_{i}=k $,则不进行操作

否则,付出 $ w_{k} $ 的代价,并选择一个 $ 1\le i\le m $,修改 $ a_{i}=k $

求最小的代价和

输入格式

第一行三个整数 $ n,m,q $,第二行 $ n $ 个整数 $ w_{1},w_{2},...,w_{n} $,第三行 $ q $ 个整数 $ k_{1},k_{2},...,k_{q} $

输出格式:

一行一个整数,表示答案

样例输入:

3 2 5
1 2 3
1 2 3 2 1

样例输出:

7

样例解释:

第一次操作修改 $ a_{1}=1 $,第二次操作修改 $ a_{2}=2 $,第三次操作修改 $ a_{1}=3 $,第四次操作无修改,第五次操作修改 $ a_{1}=1 $,代价和为 $ 1+2+3+0+1=7 $

数据范围:

$ 1\le n,q\le 5\times 10^{3} $,$ 1\le m\le 15 $,$ \forall 1\le i\le n,1\le w_{i}\le 10^{5} $,$ \forall 1\le i\le q,1\le k_{i}\le n $

Subtask1(20分): $ 1\le n\le 10 $

Subtask2(20分): $ m=2 $

Subtask3(20分): $ n=5\times 10^{3} $,$ m=15 $,$ q=400 $且$ k_{i} $在$ [1,n] $中均匀随机

Subtask4(20分): $ 1\le q\le 10^{3} $

Subtask5(20分): 无特殊限制

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.