#P3745. [六省联考 2017] 期末考试

    ID: 1299 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学贪心2017各省省选枚举,暴力前缀和

[六省联考 2017] 期末考试

Description

There are nn students. Each student took the final exams of all mm courses and is anxiously waiting for the results to be announced.

Student ii hopes to know the results of all courses on or before day tit_i. If on day tit_i at least one course has not been announced, the student will wait until the last course is announced; each day of waiting incurs CC unhappiness.

For course ii, according to the original plan, its result will be announced on day bib_i.

You can adjust announcement days using the following two operations:

  1. Move some teachers from course XX to course YY. After the adjustment, the announcement day of course XX is delayed by one day, and that of course YY is moved one day earlier. Each such operation incurs AA unhappiness.
  2. Add some teachers to course ZZ, which moves the announcement day of course ZZ one day earlier. Each such operation incurs BB unhappiness.

In both operations, the parameters XX, YY, and ZZ can be chosen arbitrarily. Each operation can be performed multiple times, and the parameters can be re-chosen each time.

Please minimize the total unhappiness by applying operations reasonably, and output the minimum possible total unhappiness.

Input Format

  • The first line contains three non-negative integers A,B,CA, B, C, which are the unhappiness costs, as described in the Description.
  • The second line contains two positive integers n,mn, m, the numbers of students and courses, respectively.
  • The third line contains nn positive integers tit_i, the desired announcement days for each student.
  • The fourth line contains mm positive integers bib_i, the originally planned announcement days for each course.

Output Format

Output a single integer on one line, the minimum total unhappiness.

100 100 2
4 5
5 1 2 3
1 1 2 3 3
6
3 5 4
5 6
1 1 4 7 8
2 3 3 1 8 2
33

Hint

Sample Explanation 1

Because the unhappiness caused by adjustments is too large, the best plan here is to make no adjustments. Among all 55 courses, the slowest is announced on day 33.
Student 11 hopes for results by day 55, so no unhappiness is incurred.
Student 22 hopes for results by day 11, so the incurred unhappiness is (31)×2=4(3 - 1) \times 2 = 4.
Student 33 hopes for results by day 22, so the incurred unhappiness is (32)×2=2(3 - 2) \times 2 = 2.
Student 44 hopes for results by day 33, so no unhappiness is incurred.
The total unhappiness is 4+2=64 + 2 = 6.

Constraints

Case # n,m,ti,bin, m, t_i, b_i A,B,CA, B, C
1, 2 1n,m,ti,bi20001 \leq n, m, t_i, b_i \leq 2000 A=109;B=109;0C102A = 10^9; B = 10^9; 0 \leq C \leq 10^2
3, 4 0A,C102;B=1090 \leq A, C \leq 10^2; B = 10^9
5, 6, 7, 8 0BA102;0C1020 \leq B \leq A \leq 10^2; 0 \leq C \leq 10^2
9 - 12 0A,B,C1020 \leq A, B, C \leq 10^2
13, 14 1n,m,ti,bi1051 \leq n, m, t_i, b_i \leq 10^5 0A,B105;C=10160 \leq A, B \leq 10^5; C = 10^{16}
15 - 20 0A,B,C1050 \leq A, B, C \leq 10^5

Translated by ChatGPT 5