#P1230. 智力大冲浪
智力大冲浪
Description
Xiaowei signed up for China Central Television (CCTV)'s “Intellectual Surfing” show. This challenge has attracted many contestants. To honor everyone’s courage, the host first awards each contestant yuan. Don’t celebrate too soon, because this money may not all be yours. Next, the host announces the rules:
First, the contest time is divided into time slots, and the host also provides many mini-games. Each mini-game must be completed before its deadline . If a game is not completed before its deadline, a penalty will be deducted from the yuan award. Here are natural numbers, and the deduction differs from game to game. Of course, every game itself is very simple: each contestant can finish any single game within one time slot, and each game must start at the beginning of a whole time slot. The host only wants to test how each contestant schedules the order of games. As a contestant, Xiaowei wants to win the championship and, of course, the most money! Note: The contest will never make contestants lose money.
Input Format
- The first line contains , the initial award for each contestant.
- The second line contains , the number of mini-games.
- The third line contains numbers, the deadlines of games through .
- The fourth line contains numbers, the penalty amounts if games through are not completed before their deadlines.
Output Format
Output a single line: the maximum amount of money Xiaowei can win.
10000
7
4 2 4 3 1 4 6
70 60 50 40 30 20 10
9950
Hint
Constraints: For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号