結果
問題 | No.447 ゆきこーだーの雨と雪 (2) |
ユーザー | kenji_shioya |
提出日時 | 2017-01-08 00:45:47 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,634 bytes |
コンパイル時間 | 3,545 ms |
コンパイル使用メモリ | 85,860 KB |
実行使用メモリ | 190,420 KB |
最終ジャッジ日時 | 2024-12-17 17:15:47 |
合計ジャッジ時間 | 116,347 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 175 ms
62,380 KB |
testcase_01 | AC | 184 ms
113,648 KB |
testcase_02 | AC | 173 ms
62,436 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
ソースコード
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(); Quiz[] quizArray = new Quiz[quizCount]; for (int i = 0; i < quizCount; i++) { Quiz entry = new Quiz(); entry.num = i; entry.getName(); entry.stars = sc.nextInt(); quizArray[i] = entry; } int submitNum = sc.nextInt(); List<Player> playerList = new ArrayList<Player>(); for (int i = 0; i < submitNum; i++) { String playerName = sc.next(); String quizName = sc.next(); Player player = getPlayer(playerList, playerName); Quiz quiz = getQuiz(quizArray, 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(); getRank(playerList, newPlayer); } } showResult(playerList); } private static void showResult(List<Player> 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<Player> 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); } if (i == playerList.size()-1) { playerList.add(i + 1, player); } } } } private static Quiz getQuiz(Quiz[] quizArray, String quizName) { Quiz quiz = null; for (Quiz q : quizArray) { if (q.name.equals(quizName)) { quiz = q; return quiz; } } return quiz; } private static Player getPlayer(List<Player> playerList, String playerName) { Player player = null; for (int i = 0; i < playerList.size(); i++) { player = playerList.get(i); if (player.name.equals(playerName)){ return player; } } return player = null; } 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; } }