QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100

#23988. 分發點心

統計

題目描述

JOI 高中的葵決定給朋友們分發點心。

葵有 $N$ 位朋友,編號從 $1$ 到 $N$。

葵有 $X$ 個冰淇淋和 $Y$ 塊巧克力。葵決定給全部 $N$ 位朋友每人分發 $1$ 個冰淇淋或巧克力(兩者之一)。這裡保證冰淇淋和巧克力加起來至少有 $N$ 個。因此,葵能夠給所有朋友都分到點心。

朋友 $i$($1 \le i \le N$)拿到冰淇淋會獲得 $A_i$ 的開心度,拿到巧克力會獲得 $B_i$ 的開心度。

請輸出葵的所有朋友獲得的開心度總和的最大可能值。

資料範圍

  • $1 \le N \le 200\,000$。
  • $0 \le X \le N$。
  • $0 \le Y \le N$。
  • $N \le X + Y$。
  • $1 \le A_i \le 10^9$($1 \le i \le N$)。
  • $1 \le B_i \le 10^9$($1 \le i \le N$)。
  • 輸入的所有值皆為整數。

子任務

  1. ($5$ 分)$N = 1$。
  2. ($5$ 分)$X = N$,$Y = 0$。
  3. ($5$ 分)$X = N$,$Y = N$。
  4. ($25$ 分)$X = N$,$Y = 1$。
  5. ($25$ 分)$X + Y = N$。
  6. ($10$ 分)$N \le 10$。
  7. ($25$ 分)無額外限制。

輸入格式

輸入以以下格式給出:

N X Y
A_1 A_2 … A_N
B_1 B_2 … B_N

輸出格式

輸出葵的所有朋友獲得的開心度總和的最大可能值。

除答案外請勿輸出任何內容。(也請勿輸出提示輸入的文字等。)

關於作答格式,可以參考練習題及其解答範例。

範例 1

輸入

2 1 1
10 20
40 30

輸出

60

葵分發點心的方法有以下 $2$ 種:

  • 給朋友 $1$ 分冰淇淋、給朋友 $2$ 分巧克力時,開心度總和為 $A_1 + B_2 = 10 + 30 = 40$。
  • 給朋友 $1$ 分巧克力、給朋友 $2$ 分冰淇淋時,開心度總和為 $B_1 + A_2 = 40 + 20 = 60$。

在這 $2$ 種方法中,開心度總和最大的是後者,此時開心度總和為 $60$。因此輸出 $60$。

本輸入範例滿足子任務 $5, 6, 7$ 的限制。

範例 2

輸入

2 2 2
10 20
40 30

輸出

70

葵分發點心的方法有以下 $4$ 種:

  • 給朋友 $1$ 和朋友 $2$ 都分冰淇淋時,開心度總和為 $A_1 + A_2 = 10 + 20 = 30$。
  • 給朋友 $1$ 分冰淇淋、給朋友 $2$ 分巧克力時,開心度總和為 $A_1 + B_2 = 10 + 30 = 40$。
  • 給朋友 $1$ 分巧克力、給朋友 $2$ 分冰淇淋時,開心度總和為 $B_1 + A_2 = 40 + 20 = 60$。
  • 給朋友 $1$ 和朋友 $2$ 都分巧克力時,開心度總和為 $B_1 + B_2 = 40 + 30 = 70$。

在這 $4$ 種方法中,開心度總和最大的是最後一種情況,此時開心度總和為 $70$。因此輸出 $70$。

本輸入範例滿足子任務 $3, 6, 7$ 的限制。

範例 3

輸入

1 1 0
1234
5678

輸出

1234

在本輸入範例中,葵只有 $1$ 位朋友。

本輸入範例滿足子任務 $1, 2, 5, 6, 7$ 的限制。

範例 4

輸入

10 10 1
314159265 358979323 846264338 327950288 419716939 937510582 97494459 230781640 628620899 862803482
534211706 798214808 651328230 664709384 460955058 223172535 940812848 111745028 410270193 852110555

輸出

5867599604

請注意,輸出結果可能無法容納於 32bit 整數型別中。

本輸入範例滿足子任務 $4, 6, 7$ 的限制。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.