Please help me with this , can't make it last 3 test cases

package com.vivekjava;

import java.util.Scanner;

public class CBWinningScholarship {

public static void main(String args[]) {
    Scanner cin = new Scanner(System.in);
    int n = cin.nextInt(),
            m = cin.nextInt(),//total discount
            x = cin.nextInt(),//100% discount
            y = cin.nextInt();//pay with discount amount

    int si = 1, li = n, ans = 0;
    while (si <= li) {
        int mid = (si + li) / 2;
        if (check(mid, n, m, x, y)) {
            si = mid + 1;
            ans = mid;
        } else {
            li = mid - 1;
        }
    }
    System.out.print(ans);
}

static boolean check(int z, int n, int m, int x, int y) {
    return z * x <= m + (n - z) * y;
}

}

Hey @vivek4988_7c34775e05f479ae Just a slight change instead of using int use long datatype bcoz the input and output can be very large so except for indexes change all the datatype to long.

oh okay thanks ,working now

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.