2023/9/6 广联达笔试


第一题

//通过18%
public class Main7 {
    public static void main(String args[]) throws Exception {
    Scanner cin=new Scanner(System.in);
    int n= cin.nextInt();
    int[] arr1=new int[n];
    int[] arr2=new int[n];
    int[] arr3=new int[n];
    for(int i=0;i<n;i++)arr1[i]=cin.nextInt();
    for(int i=0;i<n;i++)arr2[i]=cin.nextInt();
    for(int i=0;i<n;i++)arr3[i]=cin.nextInt();
    int res=0;
        Arrays.sort(arr3);
        for (int i = n-1; i >=(n+1)/2 ; i--) {
            res+=arr3[i];
        }
     System.out.println(res);
}
}

第二题

//27%
public class Main8 {
    public static void main(String args[]) throws Exception {
        Scanner cin=new Scanner(System.in);
        int n= cin.nextInt();
        int[] arr1=new int[n];
        for(int i=0;i<n;i++)arr1[i]=cin.nextInt();
        int sum=0;
        for (int i = 0; i < n; i++) {
            sum+=arr1[i];
        }


        System.out.println(sum/n);
    }
}

  目录