toj4168
若当前能覆盖的区间为[1,x],加上一个元素y后能覆盖的区间变为[1,x],[y],[1+y,x+y]
要保证y<=x+1才不会有空缺,详见代码
#include<bits/stdc++.h>
using namespace std;
#define N 100005
long long a[N],ans,now;
int main()
{int t,n,m,i;scanf("%d",&t);while(t--){scanf("%d%d",&m,&n);for(i=1;i<=m;i++) scanf("%d",a+i);sort(a+1,a+1+m);ans=now=0;i=1;while(now<n)if(i>m||a[i]>now+1) ans++,now+=now+1;else now+=a[i++];printf("%lld\n",ans);}
}