Help me in solving MONSTER1 problem

My issue

i want explanation for this problem and code

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
	public static void main (String[] args) throws java.lang.Exception
		// your code goes here

Learning course: Prepare for your DSA interviews
Problem Link: CodeChef: Practical coding for everyone

plzz refer my c++ solution for better understanding of the logic.

using namespace std;
int main() {
    int T;
    cin>> T;
    while(T--) {
         int H,X,Y;
        if(X<=Y) {
        else {