QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#23988. 派零食

Statistics

題目描述

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.