#include
using namespace std;
int main()
{int t,a,b,c,x,y;
cin>>t;
while(t–)
{
cin>>a,b,c,x,y;
if(a+b-x==y-c)
cout<<“YES\n”;
else
cout<<“NO\n”;
}
return 0;
}
It’s helpful to have the following in questions:
It’s generally not useful to have your full code, even properly formatted, unless short; just quote any part you have concerns about. In this case your code is probably short enough but you haven’t pressed 101/010 so it is recognized as code by the discussion software.
Indentation is your friend and makes debugging and communicating issues clearer. Indent statements within control structures.
You need to re-read the problem, since your attempted solution makes the wrong assumption that splitting one pile to the others is optional; it is not. There are two essential requirements:
- The total stones in the initial three piles (a,b,c) must match the total of the desired two pile configuration (x,y)
- The smaller pile in (x,y) must not be smaller than all of the (a,b,c) piles.
If these two tests are met, the split can be successfully made by dividing one of the larger piles in (a,b,c) onto the smallest pile to make the smaller of (x,y), which inevitably gives the larger value when the remaining stones are added to the other pile.