当前位置: 代码迷 >> 综合 >> HDOJ 1678 Shopaholic
  详细解决方案

HDOJ 1678 Shopaholic

热度:30   发布时间:2023-10-21 19:10:03.0

HDACM1678

排序一下,从大到小累加 水….

import java.util.Arrays;
import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();while(t-->0){int n = sc.nextInt();int price[] = new int[n];for (int i = 0; i < price.length; i++) {price[i]=sc.nextInt();}Arrays.sort(price);int ans = 0;for (int i=price.length-3;i>=0;i=i-3) {ans += price[i];}System.out.println(ans);}sc.close();}
}