CF1322D.Reality Show

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A popular reality show is recruiting a new cast for the third season! nn candidates numbered from 11 to nn have been interviewed. The candidate ii has aggressiveness level lil_i , and recruiting this candidate will cost the show sis_i roubles.

The show host reviewes applications of all candidates from i=1i=1 to i=ni=n by increasing of their indices, and for each of them she decides whether to recruit this candidate or not. If aggressiveness level of the candidate ii is strictly higher than that of any already accepted candidates, then the candidate ii will definitely be rejected. Otherwise the host may accept or reject this candidate at her own discretion. The host wants to choose the cast so that to maximize the total profit.

The show makes revenue as follows. For each aggressiveness level vv a corresponding profitability value cvc_v is specified, which can be positive as well as negative. All recruited participants enter the stage one by one by increasing of their indices. When the participant ii enters the stage, events proceed as follows:

  • The show makes clic_{l_i} roubles, where lil_i is initial aggressiveness level of the participant ii .
  • If there are two participants with the same aggressiveness level on stage, they immediately start a fight. The outcome of this is:
    • the defeated participant is hospitalized and leaves the show.
    • aggressiveness level of the victorious participant is increased by one, and the show makes ctc_t roubles, where tt is the new aggressiveness level.
  • The fights continue until all participants on stage have distinct aggressiveness levels.

It is allowed to select an empty set of participants (to choose neither of the candidates).

The host wants to recruit the cast so that the total profit is maximized. The profit is calculated as the total revenue from the events on stage, less the total expenses to recruit all accepted participants (that is, their total sis_i ). Help the host to make the show as profitable as possible.

输入格式

The first line contains two integers nn and mm ( 1n,m20001 \le n, m \le 2000 ) — the number of candidates and an upper bound for initial aggressiveness levels.

The second line contains nn integers lil_i ( 1lim1 \le l_i \le m ) — initial aggressiveness levels of all candidates.

The third line contains nn integers sis_i ( 0si50000 \le s_i \le 5000 ) — the costs (in roubles) to recruit each of the candidates.

The fourth line contains n+mn + m integers cic_i ( ci5000|c_i| \le 5000 ) — profitability for each aggrressiveness level.

It is guaranteed that aggressiveness level of any participant can never exceed n+mn + m under given conditions.

输出格式

Print a single integer — the largest profit of the show.

输入输出样例

  • 输入#1

    5 4
    4 3 1 2 1
    1 2 1 2 1
    1 2 3 4 5 6 7 8 9

    输出#1

    6
  • 输入#2

    2 2
    1 2
    0 0
    2 1 -100 -100

    输出#2

    2
  • 输入#3

    5 4
    4 3 2 1 1
    0 2 6 7 4
    12 12 12 6 -3 -5 3 10 -4

    输出#3

    62

说明/提示

In the first sample case it is optimal to recruit candidates 1,2,3,51, 2, 3, 5 . Then the show will pay 1+2+1+1=51 + 2 + 1 + 1 = 5 roubles for recruitment. The events on stage will proceed as follows:

  • a participant with aggressiveness level 44 enters the stage, the show makes 44 roubles;
  • a participant with aggressiveness level 33 enters the stage, the show makes 33 roubles;
  • a participant with aggressiveness level 11 enters the stage, the show makes 11 rouble;
  • a participant with aggressiveness level 11 enters the stage, the show makes 11 roubles, a fight starts. One of the participants leaves, the other one increases his aggressiveness level to 22 . The show will make extra 22 roubles for this.

Total revenue of the show will be 4+3+1+1+2=114 + 3 + 1 + 1 + 2=11 roubles, and the profit is 115=611 - 5 = 6 roubles.

In the second sample case it is impossible to recruit both candidates since the second one has higher aggressiveness, thus it is better to recruit the candidate 11 .

首页