D
排序后二分
# include <bits/stdc++.h>
using namespace std;
#define int long long
int n,x,y;
const int N=2e5+10;
int a[N];
signed main()
{
int T;
cin>>T;
while(T--)
{
cin>>n>>x>>y;
int sum=0,ans=0;
for(int i=1;i<=n;i++)
cin>>a[i],sum+=a[i];
//cout<<sum<<endl;
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)
{
int p1=lower_bound(a+i+1,a+n+1,sum-y-a[i])-a;
int p2=upper_bound(a+i+1,a+n+1,sum-x-a[i])-a-1;
//cout<<p1<<" "<<p2<<endl;
if(p1<=i||p1>n)p1=-1;
if(p2<=i||p2>n)p2=-1;
if(p1!=-1&&p2!=-1)
ans+=max(p2-p1+1,(int)0);
}
cout<<ans<<endl;
}
}