Regarding a failed test case

My solution to the problem is correct but unable to pass one test case even the code given by the ai is unable to pass that test case

this is my code

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

class Codechef
{

    public static void quickSort(int a[], int low, int high) {
        if (low < high) {
            int pi = partition(a, low, high);
            quickSort(a, low, pi - 1);
            quickSort(a, pi + 1, high);
        }
    }

    public static int partition(int a[], int low, int high) {
        int pivot = a[high];
        int i = (low - 1);
        for (int j = low; j < high; j++) {
            if (a[j] > pivot) {
                i++;
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
        int temp = a[i + 1];
        a[i + 1] = a[high];
        a[high] = temp;
        return i + 1;
    }
    public static void main(String[] args) throws java.lang.Exception
    {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int m = 0; m < t; m++) {
            int n = sc.nextInt();
            int x = sc.nextInt();
            int arr[] = new int[n];
            int count1 = 0, diff = 0, count2 = 0, k = 0;
            int tmp;
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
                if (arr[i] > x) {
                    diff = diff + (arr[i] - x);
                    count1++;
                } else if (arr[i] == x) {
                    count1++;
                }
                else {
                    count2++;
                }
            }
            int a[] = new int[count2];
            for (int e = 0; e < n; e++) {
                if (arr[e] < x) {
                    a[k] = arr[e];
                    k++;
                }
            }
            Codechef.quickSort(a, 0, count2 - 1);

            for (int l = 0; l < count2; l++) {
                int df = 0;
                df = x - a[l];
                if (diff >= df) {
                    diff = diff - df;
                    count1++;
                }else{
                    break;
                }
            }

            System.out.println(count1);
        }

    }
}

link to the problem Budget Allotment Practice Coding Problem