1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int, int> > v;

int main()
{
	long long int a, hp;
	cin>>a>>hp;
	pair<int, int> tmp;
	for(int i=0; i<a; i++)
	{
		cin>>tmp.first>>tmp.second;
		tmp.first=tmp.second-tmp.first;
		tmp.second=i+1;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	for(int i=a-1; i>=0; i--)
	{
		hp+=v[i].first;
		if(hp<=0){cout<<"NIE"<<endl; return 0;}
	}
	cout<<"TAK"<<endl;
	for(int i=a-1; i>=0; i--)
	{
		cout<<v[i].second<<" ";
	}
}