問題一覧 > 通常問題

No.2852 Yakitori Optimization Problem

レベル : / AI推定難易度 : 475 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 136
作問者 : dyktr_06 / テスター : ryota2357 square1001 sepa38
お気に入りにしたユーザー ProblemId : 10856 / 自分の提出
問題文最終更新日: 2024-08-20 19:22:17
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 442 MMA Contest 019 (順位表) の他の問題:

Problem Statement

$N$ skewers of yakitori are lined up in a row.

The deliciousness of the $i$-th yakitori from the left is $A_i$.

Each of these yakitori will be given a topping of either salt or tare sauce. Of the $N$ yakitori, $K$ will be topped with salt and $N - K$ will be topped with tare sauce.

Topping the $i$-th yakitori from the left with salt increases its deliciousness by $B_i$, and topping it with tare sauce increases its deliciousness by $C_i$.

Since sepa-kun wants to eat yakitori that is as delicious as possible, he decided to apply the toppings so as to maximize the total deliciousness.

Find the maximum possible value of the total deliciousness of the $N$ yakitori.


Constraints

  • $1 \leq N \leq 2 \times 10^{5}$
  • $0 \leq K \leq N$
  • $1 \leq A_i \leq 10^{9}$
  • $1 \leq B_i, C_i \leq 10^{9}$
  • All input values are integers.

Input

The input is given from standard input in the following format.

$N$ $K$ 
$A_1$ $A_2$ ... $A_N$ 
$B_1$ $B_2$ ... $B_N$ 
$C_1$ $C_2$ ... $C_N$ 

Output

Output the answer to the problem on one line.

Sample

Sample 1
Input
3 2
2 3 5
5 7 6
4 9 2
Output
30

If the $1$-st and $3$-rd yakitori from the left are topped with salt and the $2$-nd yakitori is topped with tare sauce, the total deliciousness is $(2 + 5) + (3 + 9) + (5 + 6) = 30$, which is the maximum.

Sample 2
Input
10 4
6 35 90 38 69 51 66 40 92 74
53 83 46 26 3 48 50 38 67 66
32 52 20 47 51 77 24 77 26 6
Output
1131

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。