CF332C.Students' Revenge

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

A student's life is fraught with complications. Some Berland University students know this only too well. Having studied for two years, they contracted strong antipathy towards the chairperson of some department. Indeed, the person in question wasn't the kindest of ladies to begin with: prone to reforming groups, banning automatic passes and other mean deeds. At last the students decided that she just can't get away with all this anymore...

The students pulled some strings on the higher levels and learned that the next University directors' meeting is going to discuss n orders about the chairperson and accept exactly p of them. There are two values assigned to each order: a__i is the number of the chairperson's hairs that turn grey if she obeys the order and b__i — the displeasement of the directors if the order isn't obeyed. The students may make the directors pass any p orders chosen by them. The students know that the chairperson will obey exactly k out of these p orders. She will pick the orders to obey in the way that minimizes first, the directors' displeasement and second, the number of hairs on her head that turn grey.

The students want to choose p orders in the way that maximizes the number of hairs on the chairperson's head that turn grey. If there are multiple ways to accept the orders, then the students are keen on maximizing the directors' displeasement with the chairperson's actions. Help them.

学生的生活充满了各种麻烦。一些贝尔兰大学的学生对此深有体会。在学习了两年之后,他们对某院系主任产生了强烈的反感。事实上,这位女士从一开始就不怎么和善:她热衷于重组班级、取消自动通过政策以及其他种种苛刻之举。最终,学生们决定,她不能再这样为所欲为了……

学生们动用了一些高层关系,得知下一次大学校长会议将审议关于该主任的 nn 项指令,并恰好通过其中的 pp 项。每项指令有两个数值:aia_i 表示若主任遵从该指令,则她变灰的头发数量;bib_i 表示若主任不遵从该指令,则校领导们的不满程度。学生们可以促使校领导们通过任意 pp 项由他们选定的指令。学生们知道,主任将恰好遵从这 pp 项指令中的 kk 项。她选择遵从哪些指令的方式是:首先最小化校领导们的不满程度,其次(在不满程度相同的情况下)最小化自己变灰的头发数量。

学生们希望选择 pp 项指令,以最大化主任变灰的头发总数。如果存在多种方式能达到最大变灰头发数,则学生们倾向于进一步最大化校领导们对其行为的不满程度。请帮助他们。

输入格式

The first line contains three integers n (1 ≤ n ≤ 105), p (1 ≤ p ≤ n), k (1 ≤ k ≤ p) — the number of orders the directors are going to discuss, the number of orders to pass and the number of orders to be obeyed by the chairperson, correspondingly. Each of the following n lines contains two integers a__i and b__i (1 ≤ a__i, b__i ≤ 109), describing the corresponding order.

第一行包含三个整数 nn(1≤n≤1051 \leq n \leq 10^5)、pp(1≤p≤n1 \leq p \leq n)、kk(1≤k≤p1 \leq k \leq p),分别表示导演们将要讨论的议案数量、需要通过的议案数量,以及主席必须遵守的议案数量。接下来的 nn 行,每行包含两个整数 aia_i 和 bib_i(1≤ai,bi≤1091 \leq a_i, b_i \leq 10^9),描述对应的议案。

输出格式

Print in an arbitrary order p distinct integers — the numbers of the orders to accept so that the students could carry out the revenge. The orders are indexed from 1 to n in the order they occur in the input. If there are multiple solutions, you can print any of them.

以任意顺序输出 p 个互不相同的整数——即应接受的订单编号,使得学生们能够实施报复。订单按其在输入中出现的顺序从 1 到 n 编号。若存在多个解,输出其中任意一个即可。

输入输出样例

  • 输入#1

    5 3 2
    5 6
    5 8
    1 3
    4 3
    4 11

    输出#1

    3 1 2
  • 输入#2

    5 3 3
    10 18
    18 17
    10 20
    20 18
    20 18

    输出#2

    2 4 5

说明/提示

In the first sample one of optimal solutions is to pass orders 1, 2, 3. In this case the chairperson obeys orders number 1 and 2. She gets 10 new grey hairs in the head and the directors' displeasement will equal 3. Note that the same result can be achieved with order 4 instead of order 3.

In the second sample, the chairperson can obey all the orders, so the best strategy for the students is to pick the orders with the maximum sum of a__i values. The chairperson gets 58 new gray hairs and the directors' displeasement will equal 0.

在第一个样例中,一种最优方案是执行命令 1、2、3。此时主席服从了第 1 和第 2 号命令。她头上新增了 10 根灰发,而董事们的不满值为 3。注意:用命令 4 替代命令 3 也可达到相同结果。

在第二个样例中,主席可以服从所有命令,因此学生们的最优策略是选择所有 aia_i 值之和最大的那些命令。主席新增了 58 根灰发,而董事们的不满值为 0。

输入解题思路,AI测评打分。不知道怎么写?

首页