Students' Revenge

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: ai is the number of the chairperson’s hairs that turn grey if she obeys the order and bi — 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.

Input

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 ai and bi (1 ≤ ai, bi ≤ 109), describing the corresponding order.

Output

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.

Examples

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

Input
5 3 3
10 18
18 17
10 20
20 18
20 18
Output
2 4 5

题目描述:
有n个命令,要通过p个,某主席要在通过的p个中选择k个接受。
每个任务有两个值ai,bi, ai表示如果该主席接受该命令,她的头发变灰的数量,bi表示如果该主席不接受该命令时,议员不高兴值。
对于通过的p个命令,该主席要使议员的不高兴值和最小,在相同的情况下,要使自己的头发变灰的数量尽可能的少。
让你求出通过哪p个命令,使得该主席的头发变灰的数量最多,在相同的情况下,输出使议员不高兴最大的选择。

题目分析:
这道题需要多种排序方法。
首先须知道,对于每一个选择(p命令),该主席一定是把b值最小的p-k个不接受,如果b有相同的,则尽可能使自己的头发变灰的数量最小(即放弃命令的a值尽量大)。
1.按 b:小->大 a:大->小 排序,前p-k个无论a有多大,如果选它都没用(肯定会被放弃),a不能发挥作用,所以只能在后面的n-(p-k)个里选。
2.按 a: 大->小 b:大->小 排序,选择前k个,使得a的和最大,b的和最小值也最大(因为要保证主席需要接受它)。
3.保证了k个命令a的和最大后,剩下的任务就是保证p-k个命令b的和最大了。再次像1中那样排序,选出p-k个主席肯定不会通过的(即b很小的)。

代码如下:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#define LL long long
using namespace std;
const int N=1e5+5;
struct Node{
	int a,b;
	int id,st;
}a[N];
bool cmp1(const Node &x,const Node &y)
{  //以b位第一关键字,a为第二关键字,st为第三关键字进行排序
	if(x.b!=y.b) return x.b<y.b;
	if(x.a!=y.a) return x.a>y.a;
	return x.st<y.st;
}
bool cmp2(const Node &x,const Node &y)
{  //以a为第一关键字,b为第二关键字进行排序
	if(x.a!=y.a) return x.a>y.a;
	return x.b>y.b;
}
bool vis[N];
int main()
{
	cin.tie(0); 
	ios::sync_with_stdio(false);
	int n,p,k;
	cin>>n>>p>>k;
	for(int i=1;i<=n;i++)   //初始化
	{
		cin>>a[i].a>>a[i].b;
		a[i].id=i;
		a[i].st=0;
	}
	sort(a+1,a+1+n,cmp1);   //用第一种方法排序
	for(int i=1;i<=p-k;i++) //选出p-k个肯定不会被接受的
	a[i].st=1;
	sort(a+1,a+1+n,cmp2);   //用第二种方法排序
	int cnt=0;
	for(int i=1;cnt<k;i++)  //选出k个肯定会被接受的
	if(!a[i].st)
	{
		cnt++;
		a[i].st=2;
		vis[a[i].id]=true;   //用vis记录这k个命令的id
		cout<<a[i].id<<" ";
	}
	sort(a+1,a+1+n,cmp1);
	int num=0;
	cnt=0;
	for(int i=n;num<p-k;i--)  //选出p-k个肯定不会被通过的
	{//将之前选出的k个找到,在这k个后面选p-k个肯定不会被通过的命令
		if(cnt>=k)  //即这p-k个的b肯定小于k个的b
		{
			num++;
			cout<<a[i].id<<" "; 
		}
		if(vis[a[i].id]) cnt++;
	}
	cout<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
东南亚位于我国倡导推进的“一带一路”海陆交汇地带,作为当今全球发展最为迅速的地区之一,近年来区域内生产总值实现了显著且稳定的增长。根据东盟主要经济体公布的最新数据,印度尼西亚2023年国内生产总值(GDP)增长5.05%;越南2023年经济增长5.05%;马来西亚2023年经济增速为3.7%;泰国2023年经济增长1.9%;新加坡2023年经济增长1.1%;柬埔寨2023年经济增速预计为5.6%。 东盟国家在“一带一路”沿线国家中的总体GDP经济规模、贸易总额与国外直接投资均为最大,因此有着举足轻重的地位和作用。当前,东盟与中国已互相成为双方最大的交易伙伴。中国-东盟贸易总额已从2013年的443亿元增长至 2023年合计超逾6.4万亿元,占中国外贸总值的15.4%。在过去20余年中,东盟国家不断在全球多变的格局里面临挑战并寻求机遇。2023东盟国家主要经济体受到国内消费、国外投资、货币政策、旅游业复苏、和大宗商品出口价企稳等方面的提振,经济显现出稳步增长态势和强韧性的潜能。 本调研报告旨在深度挖掘东南亚市场的增长潜力与发展机会,分析东南亚市场竞争态势、销售模式、客户偏好、整体市场营商环境,为国内企业出海开展业务提供客观参考意见。 本文核心内容: 市场空间:全球行业市场空间、东南亚市场发展空间。 竞争态势:全球份额,东南亚市场企业份额。 销售模式:东南亚市场销售模式、本地代理商 客户情况:东南亚本地客户及偏好分析 营商环境:东南亚营商环境分析 本文纳入的企业包括国外及印尼本土企业,以及相关上下游企业等,部分名单 QYResearch是全球知名的大型咨询公司,行业涵盖各高科技行业产业链细分市场,横跨如半导体产业链(半导体设备及零部件、半导体材料、集成电路、制造、封测、分立器件、传感器、光电器件)、光伏产业链(设备、硅料/硅片、电池片、组件、辅料支架、逆变器、电站终端)、新能源汽车产业链(动力电池及材料、电驱电控、汽车半导体/电子、整车、充电桩)、通信产业链(通信系统设备、终端设备、电子元器件、射频前端、光模块、4G/5G/6G、宽带、IoT、数字经济、AI)、先进材料产业链(金属材料、高分子材料、陶瓷材料、纳米材料等)、机械制造产业链(数控机床、工程机械、电气机械、3C自动化、工业机器人、激光、工控、无人机)、食品药品、医疗器械、农业等。邮箱:market@qyresearch.com

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lwz_159

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值