QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#6471. 二进制变换

Estadísticas

有 $n$ 个位。每个位 $i$ 都有一个值 $a_i$(0 或 1)以及一个关联的代价 $c_i$。我们可以改变位 $i$ 的值,代价计算方式为:在位 $i$ 改变之后,所有满足 $a_j = 1$ 的位 $j$ 的代价 $c_j$ 之和。求将每个位 $i$ 设置为指定值 $b_i$ 所需支付的最小总代价。

输入格式

第一行包含整数 $n$ ($1 \le n \le 5 \times 10^3$),表示位的数量。 第二行包含 $n$ 个整数 $c_i$ ($1 \le c_i \le 10^9$),表示与位关联的代价。 第三行包含 $n$ 个位 $a_i$ 的原始值。 第四行包含 $n$ 个位 $b_i$ 的目标值。

输出格式

输出一个数字,表示最小代价。

样例

样例输入 1

5
5 2 6 1 5
01110
10011

样例输出 1

21

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.