38pts求dalao调
查看原帖
38pts求dalao调
1268907
wangcm楼主2024/9/10 19:50
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int xh;
	int hx;
	int bianh;
}d[100001];
bool cmp(node x,node y)
{
	return (x.hx-x.xh)>(y.hx-y.xh);
}
bool cmp2(node x,node y)
{
	if(x.xh-x.hx<0&&y.xh-y.hx<0){
		return x.xh<y.xh;
	}
	return (x.hx-x.xh)>(y.hx-y.xh);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,z;
	cin>>n>>z;
	int h=z;
	for(int i=0;i<n;i++)
	{
		cin>>d[i].xh>>d[i].hx;
		d[i].bianh=i+1;
	}
	sort(d,d+n,cmp);
	sort(d,d+n,cmp2);
	string sdf="TAK";
	bool bn=true;
	for(int i=0;i<n;i++){
		int xl=d[i].hx-d[i].xh;
		h+=xl;
		if(h<=0){
			sdf="NIE";
			bn=false;
		}
	}
	cout<<sdf<<endl;
	for(int i=0;i<n;i++){
		cout<<d[i].bianh<<" ";
	}
	
	return 0;
}
2024/9/10 19:50
加载中...