public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int c = sc.nextInt();         while (c-- != 0) {             int t = sc.nextInt();             if (t < 3) {                 System.out.println(0);                 continue;             }             PriorityQueue<Integer> pq = new PriorityQueue<Integer>((o1, o2) -> {                 int x = (int) o1;                 int y = (int) o2;                 return y - x;             });             for (int i = 0; i < t; i++) {                 pq.add(sc.nextInt());             }             long count = 0;             while (true) {                 int t1 = pq.poll();                 int t2 = pq.poll();                 int t3 = pq.poll();                 if (t3 != 0) {                     count += 1;                     pq.add(t1 - 1);                     pq.add(t2 - 1);                     pq.add(t3 - 1);                 } else {                     break;                 }             }             System.out.println(count);         }     } 通过90.有case没过,我找不到。
点赞 评论
牛客网
牛客企业服务