跳到正文

个人记录

zzx2013issb

huo1234约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年10月9日
收录
2026年10月9日
更新
2026年11月11日
篇幅
约 2 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
#define int long long
#define tr tuple<int,int,int>
using namespace std;
const int N=100005;
int n,p,k;
tr a[N];
priority_queue<tr>q;
signed main(){
#ifndef XYZ
	freopen("revenge.in","r",stdin);
	freopen("revenge.out","w",stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>p>>k;
	for(int i=1;i<=n;i++)cin>>get<1>(a[i])>>get<0>(a[i]),get<0>(a[i])*=-1,get<2>(a[i])=i;
	sort(a+1,a+n+1);
	for(int i=1;i<=k;i++)q.emplace(-get<1>(a[i]),get<0>(a[i]),get<2>(a[i]));
	int z=k;
	for(int i=k+1;i<=n-(p-k);i++){
		if(tr(-get<1>(a[i]),get<0>(a[i]),get<2>(a[i]))<q.top()){
			q.pop();
			q.emplace(-get<1>(a[i]),get<0>(a[i]),get<2>(a[i]));
			z=i;
		}
	}
	while(!q.empty()){
		cout<<get<2>(q.top())<<' ';
		q.pop();
	}
	for(int i=z+1;i<=z+p-k;i++)cout<<get<2>(a[i])<<' ';
	return 0;
}
原文