zzx2013issb

· · 个人记录

#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;
}