#P3745. [六省联考 2017] 期末考试
[六省联考 2017] 期末考试
Description
There are students. Each student took the final exams of all courses and is anxiously waiting for the results to be announced.
Student hopes to know the results of all courses on or before day . If on day at least one course has not been announced, the student will wait until the last course is announced; each day of waiting incurs unhappiness.
For course , according to the original plan, its result will be announced on day .
You can adjust announcement days using the following two operations:
- Move some teachers from course to course . After the adjustment, the announcement day of course is delayed by one day, and that of course is moved one day earlier. Each such operation incurs unhappiness.
- Add some teachers to course , which moves the announcement day of course one day earlier. Each such operation incurs unhappiness.
In both operations, the parameters , , and 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 , which are the unhappiness costs, as described in the Description.
- The second line contains two positive integers , the numbers of students and courses, respectively.
- The third line contains positive integers , the desired announcement days for each student.
- The fourth line contains positive integers , 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 courses, the slowest is announced on day .
Student hopes for results by day , so no unhappiness is incurred.
Student hopes for results by day , so the incurred unhappiness is .
Student hopes for results by day , so the incurred unhappiness is .
Student hopes for results by day , so no unhappiness is incurred.
The total unhappiness is .
Constraints
| Case # | ||
|---|---|---|
| 1, 2 | ||
| 3, 4 | ||
| 5, 6, 7, 8 | ||
| 9 - 12 | ||
| 13, 14 | ||
| 15 - 20 |
Translated by ChatGPT 5
京公网安备 11011102002149号