codeforce 332C Students' Revenge

在一个复杂的博弈中,学生们必须从一系列命令中挑选出特定数量的指令,这些指令既能最大限度地增加某个主席的困扰,又能在一定程度上引起决策者的不满。任务涉及两阶段的策略选择:首先确定主席会遵循的部分命令,然后最大化剩余命令的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C. Students' Revenge
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 followingn 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.

Sample test(s)
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 
Note

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 ai values. The chairperson gets 58 new gray hairs and the directors' displeasement will equal 0.

题目意思:

有n个命令,要通过p个,某主席要在通过的p个中选择k个接受。

每个任务有两个值ai,bi, ai表示如果该主席接受该命令,她的头发变灰的数量,bi表示如果该主席不接受该命令时,议员不高兴 值。

对于通过的p个命令,该主席要使议员的不高兴值和最小,在相同的情况下,要使自己的头发变灰的数量尽可能的少。

让你求出通过哪p个命令,使得该主席的头发变灰的数量最多,在相同的情况下,输出使议员不高兴最大的选择。

题解: 贪心

第一步:先按 b: 大->小, a: 小->大排序,标记前p-k个,这p-k个一定不能在第二步选,因为b较小,而先选k个b较大的,故总是选不到他们  
第二步;按 a: 大->小, b: 大->小将第一步未标记的数对排序,选出前k个,那么就保证了选出的a的和最大
第三步:将剩下的n-k个数按 b:大->小, a:小->大排序,使选出的b的和最大,然而直接这么写wa了(注释的那一段代码wa test8),正解是记录
第二步取到最小b值得位置,然后在第一步大排序结果中去剩下的p-k个数对。个人还没发现前面那种方法有什么错误,感觉同一个数组
第一次第三次同样的排序方法排的顺序应该是一样的 

附上AC代码

/*
author: tpbluesky
time:	2015年8月7日12:20:46 
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <sstream>
#define inf 0x3f3f3f3f
#define eps 1e-8
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
const int maxn = 100005;
struct node
{
	int a, b, num, pos;
	int operator<(const node & n) const
	{
		if(b != n.b)
			return b < n.b;
		return a > n.a;
	}
}ord[maxn], temp[maxn];

int comp(node &n1, node &n2)
{
	if(n1.a != n2.a)
		return n1.a > n2.a;
	else 
		return n1.b > n2.b;
}

int n, p, k, ans[maxn];

int main()
{
    while(scanf("%d%d%d",&n,&p,&k) == 3)
    {
    	for(int i = 1;i <= n;++i)
    	{
    		scanf("%d%d",&ord[i].a,&ord[i].b);
    		ord[i].num = i;
		}
		
		sort(ord+1,ord+n+1);
		for(int i = 1;i <= n;++i)
		{
			temp[i] = ord[i];
			ord[i].pos = i;
		}
		sort(ord+1+p-k,ord+n+1,comp);
		int cnt = 1, t = inf;
		for(int i = 1+p-k;i < p+1;++i)
		{
			ans[cnt++] = ord[i].num;
			t = min(t,ord[i].pos);
		}
		/*
		sort(ord+1,ord+n+1);
		for(int i = 1;i <= p-k;++i)
			ans[cnt++] = ord[t-i].num;
		*/
		for(int i = 1;i <= p-k;++i)
			ans[cnt++] = temp[t-i].num;
		for(int i = 1;i <= p;++i)
			printf(i == p?"%d\n":"%d ",ans[i]);
	}
    return 0;
}



内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值