PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000339. Chọn bài thi tối ưu (Too Easy Problems)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chọn bài thi tối ưu (Too Easy Problems)

Too Easy Problems

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

An exam has nn problems and a time budget of TT milliseconds. Solving problem ii takes tit_i milliseconds. If you solve kk problems in total, a solved problem earns one point exactly when ai≥ka_i\ge k. Select a subset within the time budget that maximizes the score.

Input

First line: n,Tn,T. Each of the next nn lines contains ai,tia_i,t_i. Problems are numbered 1 through nn.

Output

Print the optimal score ss, then the number kk of chosen problems on the next line, then kk distinct indices in any order. The third line may be empty when k=0k=0. Any optimal valid subset is accepted; k=sk=s is not required.

Subtask

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; 1≤T≤1091\le T\le10^9; 1≤ai≤n1\le a_i\le n; 1≤ti≤1041\le t_i\le10^4.
  • Subtask 2 (30 points): 1≤n≤2⋅1051\le n\le 2\cdot10^5; 1≤T≤1091\le T\le10^9; 1≤ai≤n1\le a_i\le n; 1≤ti≤1041\le t_i\le10^4. ai=na_i=n for every ii.
  • Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le 2\cdot10^5; 1≤T≤1091\le T\le10^9; 1≤ai≤n1\le a_i\le n; 1≤ti≤1041\le t_i\le10^4.

Examples

Input 1

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

Output 1

2
3
3 1 4

Explanation

Problems 3, 1 and 4 cost 270 and earn two points. Three scoring problems would require all three problems with a ≥ 3, costing 330.

Input 2

2 100
1 787
2 788

Output 2

0
0

Explanation

No problem fits the budget.