測試數據非常強...WA 了快七八次
了解題目之後,假設測資是
10 7 4
5 5
4 5
4 5
4 5
3 5
3 5
4 4
5 3
4 3
4 3
5 3 2
4 11
5 8
5 6
4 3
9 3
那麼先用 b 的部分進行遞減排序 (上面那串其實就是排完的)
我們可以知道,這個主席他會從學生選的通過方案第一選擇得罪值高的
在選擇頭髮最少變灰色的
所以在排序完之後,學生們知道這些得罪值高的他會優先去做,所以他們還會在去排序頭髮一次
但是如果單純只考慮排序頭髮變灰的話,如上面右邊的測資,他們會選擇 9 3 這組
之後他們就無法選擇比 9 3 這組更小的得罪值了,所以我們至少要留 p-k 個在後面當作無效通過的措施,也就是墊檔用
所以我們會對 [0,n-p+k) 排序,之後我們把前 k 個都記錄起來,代表我們需要他來讓主席長頭髮,然後我們挑順序 1 比那些前 k 個還大的,就是仇恨值比較小的,用來墊檔
這其中有一個問題,之前我們用 b 做遞減排序時,如果相等的我們就隨意排,但是我們需要最嚴謹的排法
也就是說,如果我們選了
5 5
4 5
4 5
4 5
依照剛剛的講法,我會選擇
3 5 來做我的墊檔措施
但是這個墊檔措施我們不想讓主席執行,可是這個墊檔措施反而有比較好的執行優先權
因為 3 明顯比 4 還要小,所以我們一開始排序就要排如果一樣 頭髮就要選擇少的,這樣之後才不會選到更好的措施
//====================================================================||
// ||
// ||
// Author : GCA ||
// 6AE7EE02212D47DAD26C32C0FE829006 ||
//====================================================================||
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cctype>
#include <utility>
using namespace std;
#ifdef ONLINE\_JUDGE
#define ll "%lld"
#else
#define ll "%I64d"
#endif
typedef unsigned int uint;
typedef long long int Int;
#define Set(a,s) memset(a,s,sizeof(a))
#define Write(w) freopen(w,"w",stdout)
#define Read(r) freopen(r,"r",stdin)
#define Pln() printf("\\n")
#define I\_de(x,n)for(int i=0;i<n;i++)printf("%d ",x\[i\]);Pln()
#define De(x)printf(#x"%d\\n",x)
#define For(i,x)for(int i=0;i<x;i++)
#define CON(x,y) x##y
#define Pmz(dp,nx,ny)for(int hty=0;hty<ny;hty++){for(int htx=0;htx<nx;htx++){\\
printf("%d ",dp\[htx\]\[hty\]);}Pln();}
#define M 100005
#define PII pair<int,int\>
#define PB push\_back
#define oo INT\_MAX
#define Set\_oo 0x3f
#define Is\_debug true
#define debug(...) if(Is\_debug)printf("DEBUG: "),printf(\_\_VA\_ARGS\_\_)
#define FOR(it,c) for(\_\_typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define eps 1e-6
bool xdy(double x,double y){return x>y+eps;}
bool xddy(double x,double y){return x>y-eps;}
bool xcy(double x,double y){return x<y-eps;}
bool xcdy(double x,double y){return x<y+eps;}
int min3(int x,int y,int z){
int tmp=min(x,y);
return min(tmp,z);
}
int max3(int x,int y,int z){
int tmp=max(x,y);
return max(tmp,z);
}
struct ord{
int a,b;
int id,id2;
}ords\[M\];
int n,p,k;
bool cmp(ord a,ord b){
if(a.b==b.b)return a.a<b.a;
return a.b>b.b;
}
bool cmp2(ord a,ord b){
if(a.a==b.a)return a.b>b.b;
return a.a>b.a;
}
bool cmp3(int a,int b){
return ords\[a\].b>ords\[b\].b;
}
int main() {
ios\_base::sync\_with\_stdio(0);
while(~scanf("%d%d%d",&n,&p,&k)){
for(int i=0;i<n;i++){
scanf("%d%d",&ords\[i\].a,&ords\[i\].b);
ords\[i\].id=i;
}
sort(ords,ords+n,cmp);
for(int i=0;i<n;i++){
ords\[i\].id2=i;
}
sort(ords,ords+n-p+k,cmp2);
int m=-1;
for(int i=0;i<k;i++){
printf("%d ",ords\[i\].id+1);
m=max(m,ords\[i\].id2);
}
vector<int\> ans;
for(int i=0;i<n;i++){
if(ords\[i\].id2>m){
ans.PB(i);
}
}
sort(ans.begin(),ans.end(),cmp3);
if(ans.size()){
for(uint i=0;i<(uint)p-k;i++)printf("%d ",ords\[ans\[i\]\].id+1);
}
}
}