結果
問題 | No.447 ゆきこーだーの雨と雪 (2) |
ユーザー | tenten |
提出日時 | 2022-10-14 13:04:22 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 169 ms / 2,000 ms |
コード長 | 2,893 bytes |
コンパイル時間 | 2,529 ms |
コンパイル使用メモリ | 80,232 KB |
実行使用メモリ | 42,904 KB |
最終ジャッジ日時 | 2024-06-26 12:35:58 |
合計ジャッジ時間 | 7,557 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
37,436 KB |
testcase_01 | AC | 52 ms
37,268 KB |
testcase_02 | AC | 53 ms
37,220 KB |
testcase_03 | AC | 122 ms
39,968 KB |
testcase_04 | AC | 121 ms
40,028 KB |
testcase_05 | AC | 144 ms
41,340 KB |
testcase_06 | AC | 161 ms
42,168 KB |
testcase_07 | AC | 144 ms
40,828 KB |
testcase_08 | AC | 146 ms
41,260 KB |
testcase_09 | AC | 157 ms
42,260 KB |
testcase_10 | AC | 114 ms
39,076 KB |
testcase_11 | AC | 127 ms
40,576 KB |
testcase_12 | AC | 128 ms
40,400 KB |
testcase_13 | AC | 145 ms
41,872 KB |
testcase_14 | AC | 160 ms
42,428 KB |
testcase_15 | AC | 130 ms
40,356 KB |
testcase_16 | AC | 104 ms
39,224 KB |
testcase_17 | AC | 130 ms
40,308 KB |
testcase_18 | AC | 89 ms
38,460 KB |
testcase_19 | AC | 169 ms
42,904 KB |
testcase_20 | AC | 169 ms
42,432 KB |
testcase_21 | AC | 129 ms
40,248 KB |
testcase_22 | AC | 125 ms
40,464 KB |
testcase_23 | AC | 137 ms
40,980 KB |
testcase_24 | AC | 157 ms
42,420 KB |
testcase_25 | AC | 167 ms
42,716 KB |
testcase_26 | AC | 144 ms
41,472 KB |
testcase_27 | AC | 139 ms
40,976 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] levels = new int[n]; for (int i = 0; i < n; i++) { levels[i] = sc.nextInt(); } int[] ranks = new int[n]; int t = sc.nextInt(); HashMap<String, Player> players = new HashMap<>(); Player.size = n; for (int i = 0; i < t; i++) { String name = sc.next(); int idx = sc.next().charAt(0) - 'A'; ranks[idx]++; if (!players.containsKey(name)) { players.put(name, new Player(name)); } players.get(name).addScore(idx, 50 * levels[idx] + 500 * levels[idx] / (8 + 2 * ranks[idx]), i); } ArrayList<Player> ans = new ArrayList<>(); ans.addAll(players.values()); Collections.sort(ans); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ans.size(); i++) { sb.append(i + 1).append(" ").append(ans.get(i)).append("\n"); } System.out.print(sb); } static class Player implements Comparable<Player> { static int size; String name; int[] scores; int sum; int last; public Player(String name) { this.name = name; scores = new int[size]; } public void addScore(int idx, int value, int time) { scores[idx] = value; sum += value; last = time; } public int compareTo(Player another) { if (sum == another.sum) { return last - another.last; } else { return another.sum - sum; } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(name).append(" "); for (int x : scores) { sb.append(x).append(" "); } sb.append(sum); return sb.toString(); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }