結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー tentententen
提出日時 2020-12-04 14:50:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 2,313 bytes
コンパイル時間 4,916 ms
コンパイル使用メモリ 76,436 KB
実行使用メモリ 46,224 KB
最終ジャッジ日時 2023-10-13 03:29:59
合計ジャッジ時間 11,719 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
39,184 KB
testcase_01 AC 116 ms
39,460 KB
testcase_02 AC 117 ms
39,312 KB
testcase_03 AC 186 ms
41,848 KB
testcase_04 AC 196 ms
41,704 KB
testcase_05 AC 224 ms
44,588 KB
testcase_06 AC 233 ms
45,664 KB
testcase_07 AC 218 ms
44,832 KB
testcase_08 AC 211 ms
42,816 KB
testcase_09 AC 234 ms
44,916 KB
testcase_10 AC 176 ms
41,460 KB
testcase_11 AC 205 ms
42,696 KB
testcase_12 AC 186 ms
41,920 KB
testcase_13 AC 230 ms
44,660 KB
testcase_14 AC 241 ms
44,784 KB
testcase_15 AC 205 ms
42,548 KB
testcase_16 AC 187 ms
41,644 KB
testcase_17 AC 206 ms
42,608 KB
testcase_18 AC 176 ms
40,724 KB
testcase_19 AC 245 ms
46,224 KB
testcase_20 AC 243 ms
45,240 KB
testcase_21 AC 200 ms
42,700 KB
testcase_22 AC 195 ms
42,132 KB
testcase_23 AC 218 ms
43,884 KB
testcase_24 AC 232 ms
45,580 KB
testcase_25 AC 245 ms
46,140 KB
testcase_26 AC 222 ms
44,696 KB
testcase_27 AC 220 ms
44,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Person.size = n;
        int[] diffs = new int[n];
        for (int i = 0; i < n; i++) {
            diffs[i] = sc.nextInt();
        }
        int[] counts = new int[n];
        HashMap<String, Person> results = new HashMap<>();
        int t = sc.nextInt();
        for (int i = 0; i < t; i++) {
            String name = sc.next();
            int idx = sc.next().charAt(0) - 'A';
            if (!results.containsKey(name)) {
                results.put(name, new Person(name));
            }
            counts[idx]++;
            results.get(name).add(i, idx, (int)(50 * diffs[idx] + 50 * diffs[idx] / (0.8 + 0.2 * counts[idx])));
        }
        Person[] persons = new Person[results.size()];
        int idx = 0;
        for (Person p : results.values()) {
            persons[idx] = p;
            idx++;
        }
        Arrays.sort(persons);
        StringBuilder sb = new StringBuilder();
        int order = 1;
        for (Person p : persons) {
            sb.append(order).append(" ").append(p).append("\n");
            order++;
        }
        System.out.print(sb);
    }
    
    
    static class Person implements Comparable<Person> {
        static int size;
        String name;
        int[] scores;
        int sum;
        int last;
        
        public Person(String name) {
            this.name = name;
            scores = new int[size];
            sum = 0;
            last = 0;
        }
        
        public void add(int times, int idx, int value) {
            sum += value;
            last = times;
            scores[idx] = value;
        }
        
        public int compareTo(Person another) {
            if (sum == another.sum) {
                return last - another.last;
            } else {
                return another.sum - sum;
            }
        }
        
        public String toString() {
            StringBuilder sb = new StringBuilder();
            sb.append(name);
            for (int i = 0; i < size; i++) {
                sb.append(" ").append(scores[i]);
            }
            sb.append(" ").append(sum);
            return sb.toString();
        }
    }
    
}
0