# Codeforces B. Too Easy Problems

## 题目描述：

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly ti milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.

Unfortunately, your teacher considers some of the problems too easy for you. Thus, he assigned an integer ai to every problem i meaning that the problem i can bring you a point to the final score only in case you have solved no more than ai problems overall (including problem i).

Formally, suppose you solve problems p1, p2, ..., pk during the exam. Then, your final score s will be equal to the number of values of jbetween 1 and k such that k ≤ apj.

You have guessed that the real first problem of the exam is already in front of you. Therefore, you want to choose a set of problems to solve during the exam maximizing your final score in advance. Don't forget that the exam is limited in time, and you must have enough time to solve all chosen problems. If there exist different sets of problems leading to the maximum final score, any of them will do.

Input

The first line contains two integers n and T (1 ≤ n ≤ 2·105; 1 ≤ T ≤ 109) — the number of problems in the exam and the length of the exam in milliseconds, respectively.

Each of the next n lines contains two integers ai and ti (1 ≤ ai ≤ n; 1 ≤ ti ≤ 104). The problems are numbered from 1 to n.

Output

In the first line, output a single integer s — your maximum possible final score.

In the second line, output a single integer k (0 ≤ k ≤ n) — the number of problems you should solve.

In the third line, output k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the indexes of problems you should solve, in any order.

If there are several optimal sets of problems, you may output any of them.

Examples

input

5 300
3 100
4 150
4 80
2 90
2 300

output

2
3
3 1 4

input

2 100
1 787
2 788

output

0
0

input

2 100
2 42
2 58

output

2
2
1 2

Note

In the first example, you should solve problems 3, 1, and 4. In this case you'll spend 80 + 100 + 90 = 270 milliseconds, falling within the length of the exam, 300 milliseconds (and even leaving yourself 30 milliseconds to have a rest). Problems 3 and 1 will bring you a point each, while problem 4 won't. You'll score two points.

In the second example, the length of the exam is catastrophically not enough to solve even a single problem.

In the third example, you have just enough time to solve both problems in 42 + 58 = 100 milliseconds and hand your solutions to the teacher with a smile.

## 思路：

2　　　　2　　3　　　　4　　4

300　　90　　100　　150　　80

## 知识点：priority_queue

1 struct node
2 {
3     int x,y;
4     bool operator < (const node & a) const
5     {
6         return x<a.x;
7     }
8 };
9 priority_queue <node> q;
priority_queue <int,vector<int>,less<int> > p;priority_queue <int,vector<int>,greater<int> > q;

 1 #include <iostream>
2 #include <vector>
3 #include <queue>
4 #define max_n 200005
5 using namespace std;
6 vector<pair<int,int> > vec[max_n];
7 struct node
8 {
9     int id;
10     int time;
11     friend bool operator<(node a,node b)
12     {
13         return a.time<b.time;
14     }
15 };
16
17 priority_queue<node> que;
18 int n;
19 int T;
20 int main()
21 {
22     cin >> n >> T;
23     for(int i = 0;i<n;i++)
24     {
25         int num,time;
26         cin >> num >> time;
27         vec[num].push_back(pair<int,int>(time,i));
28     }
29     int sum = 0;
30     int score = 0;
31     for(int i = n;i>=0;i--)
32     {
33         for(int j = 0;j<vec[i].size();j++)
34         {
35             node p;
36             p.id = vec[i][j].second+1;
37             p.time = vec[i][j].first;
38             que.push(p);
39             sum += p.time;
40         }
41         while(que.size()>i)
42         {
43             int t= que.top().time;
44             que.pop();
45             sum -= t;
46         }
47         score = i;
48         if(que.size()==i&&sum<=T)
49         {
50             break;
51         }
52     }
53
54     cout << que.size() << endl;
55     cout << score << endl;
56     while(que.size())
57     {
58         cout << que.top().id << " ";
59         que.pop();
60     }
61     return 0;
62 }

posted @ 2019-07-20 00:05 小张人 阅读(...) 评论(...) 编辑 收藏