請各位大神幫我看看為什麼會出現MLE的情形,感覺程式碼邏輯都正確以及使用隨機測資都可以正常運行QQ,請告訴我該如何修改~
import java.util.*;
public class main{
public static void main(String[] args){
Scanner k = new Scanner(System.in);
int cases = k.nextInt();
for(int i = 0 ;i<cases ;i++){
int num_relative = k.nextInt();
int[] address = new int[num_relative];
int house = 0;
int distan = 0;
for(int j = 0;j<num_relative;j++){
address[j] = k.nextInt();
}
Arrays.sort(address);
house = address[(num_relative/2)];
for(int p =0;p<num_relative;p++){
distan = distan+Math.abs(house - address[p]);
}
System.out.println(distan);
}
}
}