this is the ques

https://www.codechef.com/LTIME95C/problems/BENCHP

I am getting TLE

#include

#include<bits/stdc++.h>

using namespace std;

int main()

{

int t,n,w,wr,i,p,ans,tot,j,c;

cin>>t;

while(t–)

{

w=0;tot=0;

cin>>n >> w >> wr;

int arr[n];

for(i=0;i<n;i++)

{

cin>>arr[i];

}

//logic…

if(wr>=w)

cout<<“YES”<<endl;

else

```
{
sort(arr,arr+n);
i=0;
while(i<n)
{
j=i+1;
while(j<n)
{
if(arr[i]!=arr[j])
break;
j++;
c++;
if(c>1)
{
tot=tot+c*arr[i];
if(c%2==1)
tot=tot-arr[i];
if(tot>=w)
break;
}
i=j;
}
if(tot>=w)
cout<<"YES"<<endl;
else
cout<<"YES"<<endl;
}
}
}
return 0;
```

}