help be debug the warrior chef problem it is telling time exceede in test case 4 can you explain me.

include <stdio.h>

int main(void) {
// your code goes here
int a,i;
scanf(“%d”,&a);
for(i=0;i<a;i++){
int arr[2];
int j;
for(j=0;j<2;j++){
scanf(“%d”,&arr[j]);
}
int h=arr[1];
int n=arr[0];
int arry[n];
for(j=0;j<n;j++){
scanf(“%d”,&arry[j]);
}
int x=0;
int win=1;
while(win!=0){

        for(j=0;j<n;j++){
            if(x>=arry[j]){
                arry[j]=0;
            }
        }
        
        int totalpower = 0;
        for(j=0;j<n;j++){
            totalpower=totalpower+arry[j];
        }
        
        if((h-totalpower)>0){
            printf("%d\n",x);
            win=0;
        }
        if((h-totalpower<=0)){
            x = x + 1;
        }
    }
    
    
}
return 0;

}

@mu219301362_5g
plzz send the problem link.