ArrayList<Integer> a = new ArrayList<>(); for (int i = 0; i < n; i++) { a.add(in.nextInt()); }
Collections.sort(a); Collections.reverse(a);
ArrayList<Integer> a1 = new ArrayList<>(); ArrayList<Integer> a2 = new ArrayList<>();
// 第一个小区 for (int i = 0; i < Math.min(n1, n2); i++) { a1.add(a.get(i)); } // 第二个小区 for (int i = Math.min(n1, n2); i < Math.max(n1, n2)+Math.min(n1,n2); i++) { a2.add(a.get(i)); }
Double res = 0.00000; Double tempSum = 0.0; for (int i = 0; i < a1.size(); i++) { tempSum += Double.valueOf(a1.get(i)); } res = Double.valueOf(tempSum/a1.size()); tempSum = 0.0; for (int i = 0; i < a2.size(); i++) { tempSum += Double.valueOf(a2.get(i)); } res += Double.valueOf(tempSum/a2.size());
publicstaticvoidmain(String[] args){ Scanner in = new Scanner(System.in); while (in.hasNextInt()){ int n = in.nextInt(); int m = in.nextInt(); int k = in.nextInt();
int res = 0;
// 邻接矩阵 int[][] mux = newint[n][n]; for (int i = 0; i < m; i++) { int v1 = in.nextInt(); int v2 = in.nextInt(); int w = in.nextInt();
mux[v1-1][v2-1] = w; mux[v2-1][v1-1] = w; } for (int i = 0; i < mux.length; i++) { for (int j = i; j < mux[i].length; j++) {