Guest User

Untitled

a guest
Jul 28th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include "iostream"
  2. #include "bits/stdc++.h"
  3. #include "algorithm"
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n,d,e,p;
  9. //No. of test cases
  10. cin >> n;
  11.  
  12. long a[3],b[2];
  13. for (int i = 1; i <= n; i++)
  14. {
  15. for(int i=0;i<3;i++)
  16.  
  17. //a,b,c input
  18. cin>>a[i];
  19.  
  20. //x,y input
  21. cin >> b[0]>> b[1];
  22.  
  23. // sorting
  24. sort(a, a+3);
  25. sort(b, b+2);
  26.  
  27. // assigning smallest value of a, b, c to d and x, y to e
  28. d = a[0];
  29. e = b[0];
  30.  
  31. if(e >= d)
  32. {
  33. p = e - d;
  34. //checking if difference of smallest number is less than second largest number
  35. if(p <= a[1])
  36. {
  37. a[1] = a[1] - p;
  38. if(a[1] + a[2] == b[1])
  39. {
  40. cout<<"YES";
  41. }
  42. else
  43. cout<<"NO";
  44. }
  45. else
  46. cout<<"NO";
  47. }
  48. else
  49. cout<<"NO";
  50. }
  51. return 0;
  52. }
Add Comment
Please, Sign In to add comment