Advertisement
Saleh127

Untitled

Apr 25th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,n,s,a[1000],b[1000],i,j,k,l,m;
  6. cin>>t;
  7. while(t--)
  8. {
  9. m=0;
  10. cin>>n>>s;
  11. for(i=0;i<n;i++)
  12. {
  13. cin>>a[i];
  14. }
  15. for(i=0;i<n;i++)
  16. {
  17. cin>>b[i];
  18. }
  19. for(i=0;i<n;i++)
  20. {
  21. if(m) break;
  22. for(j=0;j<n;j++)
  23. {
  24. if(b[i]==0 && b[j]==1)
  25. {
  26. if(a[i]+a[j]+s<=100)
  27. {
  28. m=1;
  29. break;
  30. }
  31. }
  32. else if(b[i]==1 && b[j]==0)
  33. {
  34. if(a[i]+a[j]+s<=100)
  35. {
  36. m=1;
  37. break;
  38. }
  39. }
  40. }
  41. }
  42. if(m) printf("yes\n");
  43. else printf("no\n");
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement