Difficult Player Grouping JAVA 未验证AC

来源:互联网 发布:狼人杀抿身份数据 编辑:程序博客网 时间:2024/06/05 08:59
import java.util.ArrayList;import java.util.Arrays;import java.util.Collection;import java.util.Collections;import java.util.Scanner;public class Main {public static void main(String[] args) {// TODO Auto-generated method stubScanner scanner = new Scanner(System.in);int T = scanner.nextInt();int[] result = new int[T];while (T-- > 0) {// 英雄个数int heroNumber = scanner.nextInt();int[] choiceList = new int[heroNumber];for (int index = 0; index < heroNumber; index++) {choiceList[index] = scanner.nextInt();}int groupNumber = 0;Arrays.sort(choiceList);while (choiceList[heroNumber - 1] != 0 && choiceList[heroNumber - 2] != 0&& choiceList[heroNumber - 3] != 0) {choiceList[heroNumber - 1] = choiceList[heroNumber - 1] - 1;choiceList[heroNumber - 2] = choiceList[heroNumber - 2] - 1;choiceList[heroNumber - 3] = choiceList[heroNumber - 3] - 1;groupNumber++;Arrays.sort(choiceList);}result[T] = groupNumber / 2;}for (int index = result.length - 1; index >= 0; index--) {System.out.println(result[index]);}}}

0 0
原创粉丝点击