You are preparing for an exam on scheduling theory. The exam will last for exactly Tmilliseconds 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 j between 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.

Example

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 = 100milliseconds and hand your solutions to the teacher with a smile.

题解:

通过优先队列每次把所有分数为i的元素按照时间从大到下出队列知道队列中只剩下i个元素为止,如果当前SumTime<t && pq.size()==i,则当前解为最优解,。

AC代码为:

#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn=2e5+; struct node{
int lie;
int ai;
int time;
} stu[maxn]; bool cmp(node a,node b)
{
return a.time < b.time ;
} struct comp{
bool operator()(const node a,const node b)
{
if(a.ai!=b.ai)
return a.ai>b.ai;
return a.time<b.time;
}
}; priority_queue<node,vector<node>,comp> pq; int main()
{
int n,T,cnt=;
cin>>n>>T;
for(int i=;i<n;i++)
{
cin>>stu[i].ai>>stu[i].time;
stu[i].lie=i+;
} sort(stu,stu+n,cmp); for(int i=;i<n;i++)
{
if(stu[i].time > T)
break;
if(stu[i].ai>cnt)
{
T-=stu[i].time;
pq.push(stu[i]);
cnt++;
} while(!pq.empty() && pq.top().ai<cnt)
{
cnt--;
T+=pq.top().time;
pq.pop();
} } cout<<cnt<<endl;
cout<<cnt<<endl; while(!pq.empty())
{
cout<<pq.top().lie<<" ";
pq.pop();
}
cout<<endl; return ;
}

CoderForces-913D的更多相关文章

  1. Codeforces 913D - Too Easy Problems

    913D - Too Easy Problems 思路:二分check k 代码: #include<bits/stdc++.h> using namespace std; #define ...

  2. coderforces #387 Servers(模拟)

    Servers time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

  3. coderforces #384 D Chloe and pleasant prizes(DP)

    Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  4. coderforces 731c

    题目大意:给出m组数据,每组数据包括两个数Li与Ri,分别表示左右袜子的索引(下标),表示这一天要穿的袜子:而我们要使得每天穿的这两只袜子的颜色相同,所以可以改变袜子的颜色,每次只能改变一只袜子的颜色 ...

  5. coderforces 721b

    题目描述: B. Passwords time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. CoderForces 280B(记忆化搜索)

    题目大意:一个纸牌游戏,52张纸牌排成一列,每张纸牌有面值和花色两种属性.每次操作可以用最后一张纸牌将倒数第二张或者倒数第四张替换,但前提是两张牌的花色或者面值相同.问最终能否只剩一张牌. 题目分析: ...

  7. CoderForces 689A Mike and Cellphone (水题)

    题意:给定一个手机键盘数字九宫格,然后让你判断某种操作是不是唯一的,也就是说是不是可以通过平移也能实现. 析:我的想法是那就平移一下,看看能实现,就四种平移,上,下,左,右,上是-3,要注意0变成8, ...

  8. CoderForces 518C Anya and Smartphone (模拟)

    题意:给定一个手机,然后一共有 n 个app,告诉你每个屏幕最多放 k 个,现在要你运行 m 个app,每次都从第一个屏幕开始滑动,每运行一个,它就和前一个交换位置,第一个就不换了,现在问你要滑动多少 ...

  9. CoderForces 518D Ilya and Escalator (期望DP)

    题意:给定 n 个人,在每一时刻一个人进入地铁的概率是 p,站着不动的概率是 1-p,然后问你 t 时间地铁里有多少人. 析:很明显这是一个期望DP,用d[i][j]表示 i 时刻 j 个人进入地铁的 ...

  10. CoderForces 687C The Values You Can Make (01背包,DP)

    题意:给定 n 个硬币和一个值 k,问你在用一些硬币组成面值为 k的这些硬币还能组成多少种其他面值. 析:如果这样说,由这些硬币能组成多少种不同的面值,那么是不是就很熟悉了,这不就是01背包么,这个题 ...

随机推荐

  1. avtivmq(订阅写法)

    发布-订阅消息模式与点对点模式类似,只不过在session创建消息队列时,由session.createQuene()变为session.createTopic(). 消息发布者代码: 消息订阅者代码 ...

  2. C# II: Class ViewModelBase and RelayCommand in MVVM

    好久不写WPF和MVVM,新建一个Project后,想起来ViewModelBase和RelayCommand没有.以下Code摘自MSDN上的Article:Patterns - WPF Apps ...

  3. java编程思想第四版第九章习题

    第三题 package net.mindview.interfaces; abstract class Base{ public Base(){ print(); } abstract void pr ...

  4. 关于RAID 5的介绍与创建

    一.简介 定义: RAID 5是RAID 0和RAID 1的折中方案.RAID 5具有和RAID0相近似的数据读取速度,只是多了一个奇偶校验信息,写入数据的速度比对单个磁盘进行写入操作稍慢.同时由于多 ...

  5. ArcGIS API For Javascript:热力图不同级别下的优化方法

    我们在地图缩放的不同级别下,热力图的显示效果会不同,由于点密度与模糊参数默认是固定的,因此需要对参数进行动态修改,以满足不同缩放级别下可以得到较好的显示效果. 思路是监听地图缩放级别,将地图缩放级别作 ...

  6. SpringBoot系列之切换log4j日志框架

    SpringBoot系列之使用切换log4j日志框架 ok,在pom文件右键->Diagrams->show Dependencies....,如图,找到spring-boot-start ...

  7. 初探three.js光源

    上一节我们简单的说了一下THREE中必要的元素.今天我们深入探讨一下各种THREE的光源. 一 基础光源 基础光源有4种1.THREE.AmbientLight(环境光源)2.THREE.PointL ...

  8. 2019 牛客网 第七场 H pair

     题目链接:https://ac.nowcoder.com/acm/contest/887/H  题意: 给定A,B,C问在[1,A]和[1,B]中有多少对x,y满足x&y>C或者x^y ...

  9. Mybatis拦截器实现原理深度分析

    1.拦截器简介 拦截器可以说使我们平时开发经常用到的技术了,Spring AOP.Mybatis自定义插件原理都是基于拦截器实现的,而拦截器又是以动态代理为基础实现的,每个框架对拦截器的实现不完全相同 ...

  10. Flask入门学习——蓝图Blueprint

    flask蓝图可以实现应用程序的模块化,即通常作用于相同的url前缀,eg:/user/id,/user/profile等类似这样,可以放在一个模块当中,这样会让应用更加清晰便于开发与维护. 这里有个 ...