#P10001. [集训队互测 2023] 优惠购物
[集训队互测 2023] 优惠购物
Problem Description
Xiao C wants to buy items. These items have prerequisite relations and must be bought in order (that is, he can only buy item after buying item ).
Initially, he has coupons and infinitely many coins. Each item has two attributes: price and coupon usage limit .
The process of buying one item is as follows:
- Choose to use coupons, and pay coins and coupons.
- After the purchase, he can get coupons (that is, in one purchase, for every coins paid, he gets one coupon; is a given constant).
Xiao C wants to find the minimum number of coins needed to buy all items.
Input Format
This problem contains multiple test cases. The first line contains an integer , indicating the number of test cases.
For each test case:
- The first line contains three integers .
- The second line contains integers , representing the prices of the items.
- The third line contains integers , representing the coupon usage limits.
Output Format
For each test case, output one line:
- Output one integer, representing the minimum number of coins required.
4
6 16 2
17 14 13 5 13 4
12 5 5 2 10 2
6 4 2
8 1 20 10 4 10
8 1 15 3 4 6
5 40 7
21 47 7 25 47
9 26 4 4 39
5 151 10
86 84 164 158 160
43 42 82 79 80
34
34
95
463
见附件 ex_shop2.in。
见附件 ex_shop2.out。
Hint
For all testdata, $1\le \sum n\le 10^6,0\le m,a_i,b_i\le 10^9,2\le c\le 10^9$.
- Subtask 1 (5 pts): $1\le T\le 5,1\le n\le 10,1\le m,\sum a_i,\sum b_i\le 10$
- Subtask 2 (10 pts):
- Subtask 3 (10 pts): $1\le \sum n\le 500,1\le \sum m,\sum a_i,\sum b_i\le 500$
- Subtask 4 (10 pts): $1\le \sum n\le 6000,1\le \sum m,\sum a_i,\sum b_i\le 6000$
- Subtask 5 (10 pts):
- Subtask 6 (15 pts):
- Subtask 7 (10 pts):
- Subtask 8 (15 pts):
- Subtask 9 (15 pts):
Time limit: .
Memory limit: .
Translated by ChatGPT 5