import java.util.*; import java.math.BigDecimal; public class Rain2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int quizCount = sc.nextInt(); Map quizMap = new HashMap(); for (int i = 0; i < quizCount; i++) { Quiz entry = new Quiz(); entry.num = i; entry.getName(); entry.stars = sc.nextInt(); quizMap.put(entry.name, entry); } int submitNum = sc.nextInt(); Map playerMap = new HashMap(); List playerList = new ArrayList(); for (int i = 0; i < submitNum; i++) { String playerName = sc.next(); String quizName = sc.next(); Player player = playerMap.get(playerName); Quiz quiz = quizMap.get(quizName); if (player != null) { player.scores[quiz.num] = calcPoint(quiz.stars, quiz.acCount); quiz.acCount += 1; player.getSum(); getRank(playerList, player); } else { Player newPlayer = new Player(quizCount); newPlayer.name = playerName; newPlayer.scores[quiz.num] = calcPoint(quiz.stars, quiz.acCount); quiz.acCount += 1; playerList.add(newPlayer); newPlayer.getSum(); playerMap.put(playerName, newPlayer); getRank(playerList, newPlayer); } } showResult(playerList); } private static void showResult(List playerList) { for (int i = 0; i < playerList.size(); i++) { Player player = playerList.get(i); String point = ""; for (int j = 0; j < player.scores.length; j++) { point += player.scores[j] + " "; } System.out.println((i + 1) + " " + player.name + " " + point + player.sum); } } private static void getRank(List playerList, Player player) { if (playerList.size() > 1){ playerList.remove(player); int size = playerList.size(); for (int i = 0; i < size; i++) { if (player.sum > playerList.get(i).sum) { playerList.add(i, player); return; } if (i == playerList.size()-1) { playerList.add(i + 1, player); } } } } private static int calcPoint(int stars, int acCount){ BigDecimal a = new BigDecimal(stars); BigDecimal b = new BigDecimal(acCount); BigDecimal c = new BigDecimal("0.8"); BigDecimal d = new BigDecimal("0.2"); BigDecimal e = new BigDecimal(50*stars); return (stars * 50 + e.divide(c.add(d.multiply(b)), 0, BigDecimal.ROUND_FLOOR).intValue()); } } class Quiz { public String name; public int stars; public int num; public int acCount = 1; public void getName() { String[] nameArray = {"A","B","C","D","E","F","G","H","I","J","K","L", "M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; this.name = nameArray[this.num]; } } class Player { public String name; public int[] scores; public int sum; public Player(int quizCount) { scores = new int[quizCount]; for (int i = 0; i < quizCount; i++) { scores[i] = 0; } } public void getSum() { int sum = 0; for (int num : scores) { sum += num; } this.sum = sum; } }