排个序
1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class P1025 5 { 6 public static void main(String args[]) 7 { 8 try (Scanner cin = new Scanner(System.in)) 9 { 10 while (cin.hasNext()) 11 { 12 int n = cin.nextInt(); 13 int a[] = new int[n]; 14 for (int i = 0; i < n; i++) 15 a[i] = cin.nextInt(); 16 Arrays.sort(a); 17 int result = 0; 18 for (int i = 0; i <= n / 2; i++) 19 result += a[i] / 2 + 1; 20 System.out.println(result); 21 } 22 } 23 } 24 }
时间: 2024-10-02 18:59:47