QOJ.ac

QOJ

时间限制: 2 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#16895. 特別賞

统计

$N$ 人の学生が美術大会に参加した。この大会では、主催者1名と審査員1名が受賞者を決定する。受賞者の決定方法は以下の通りである。

  1. 主催者と審査員がそれぞれすべての学生の作品に点数をつける。両者とも、点数をつける際に異なる2つの作品に同じ点数をつけることはない。
  2. 主催者が $M$ 人の学生を選び、特別賞を授与する。
  3. 審査員は、特別賞を受けなかった学生の作品のうち、自分がつけた点数が高い順に $K$ 個の作品を選び、その $K$ 人の学生に本賞を授与する。

主催者は、賞の種類に関わらず、賞を受ける学生の作品に対して自分がつけた点数の合計が最大になるようにしたい。可能な合計の最大値を求めよ。

入力

1行目に、全学生数 $N$、特別賞を授与する学生数 $M$、本賞を授与する学生数 $K$ が空白区切りで与えられる。 ($2 \le N \le 2 \times 10^5$; $1 \le M, K \le N - 1$; $M + K \le N$)

2行目から $N$ 行にわたって、各作品に対して主催者がつけた点数 $a_i$ と審査員がつけた点数 $b_i$ が空白区切りで与えられる。 ($0 \le a_i, b_i \le 10^9$) 点数はすべて整数であり、$i \neq j$ に対して $a_i \neq a_j, b_i \neq b_j$ を満たす。

出力

賞を受ける $M + K$ 人の学生が描いた作品に対して、主催者がつけた点数の合計の最大値を出力せよ。

入出力例

入力 1

7 2 3
4 7
7 8
2 1
9 3
6 0
10 4
3 6

出力 1

33

注記

主催者が1番目と4番目の学生を選んで特別賞を与える場合、審査員は自分がつけた点数に従って2番目、6番目、7番目の学生に賞を与えることになる。このとき、賞を受けた5人の作品に対して主催者がつけた点数の合計は33となり、これが可能な最大値であることが証明できる。

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.