#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
for(int k=0;k<t;k++)
{
int s,n;
cin>>n>>s;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
vector<int>def;
vector<int>forw;
int p=0;
for(int i=0;i<n;i++)
{
p=a[i];
if(arr[i]==1)
{
forw.push_back(p);
}
if(arr[i]==0)
{
def.push_back(p);
}
}
sort(def.begin(),def.end());
sort(forw.begin(),forw.end());
int sum=s+def.front()+forw.front();
if(sum>100)
{
cout<<"no"<<endl;
}
else
{
cout<<"yes"<<endl;
}
}
}
//The question is of a previous lunchtime div.2
// Problem Code: **FFL**
// Chef in Fantasy League
//i cant find the runtime error(SIGSEGV) in the code but i cant figure out what random memory i am accessing
It is not necessary that forw.size()>0 and def.size()>0.
eg-
1
3 50
10 20 30
0 0 0
Here there will be no element in forw .So,using forw.front() will give SIGSEGV
Sorry…
1 Like