結果
問題 | No.449 ゆきこーだーの雨と雪 (4) |
ユーザー | 37zigen |
提出日時 | 2016-11-22 21:31:18 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,379 ms / 5,000 ms |
コード長 | 2,436 bytes |
コンパイル時間 | 4,340 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 89,708 KB |
最終ジャッジ日時 | 2024-09-22 10:30:24 |
合計ジャッジ時間 | 51,161 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 134 ms
54,484 KB |
testcase_01 | AC | 134 ms
54,116 KB |
testcase_02 | AC | 128 ms
54,076 KB |
testcase_03 | AC | 211 ms
54,780 KB |
testcase_04 | AC | 205 ms
54,828 KB |
testcase_05 | AC | 211 ms
54,792 KB |
testcase_06 | AC | 205 ms
54,864 KB |
testcase_07 | AC | 209 ms
54,640 KB |
testcase_08 | AC | 208 ms
54,444 KB |
testcase_09 | AC | 210 ms
54,824 KB |
testcase_10 | AC | 200 ms
54,748 KB |
testcase_11 | AC | 208 ms
54,924 KB |
testcase_12 | AC | 1,244 ms
79,252 KB |
testcase_13 | AC | 1,288 ms
81,148 KB |
testcase_14 | AC | 1,270 ms
83,644 KB |
testcase_15 | AC | 1,231 ms
82,880 KB |
testcase_16 | AC | 1,313 ms
81,796 KB |
testcase_17 | AC | 1,355 ms
80,912 KB |
testcase_18 | AC | 1,248 ms
79,036 KB |
testcase_19 | AC | 1,308 ms
82,428 KB |
testcase_20 | AC | 1,359 ms
81,704 KB |
testcase_21 | AC | 1,321 ms
80,988 KB |
testcase_22 | AC | 1,304 ms
81,416 KB |
testcase_23 | AC | 1,254 ms
78,636 KB |
testcase_24 | AC | 1,333 ms
82,824 KB |
testcase_25 | AC | 1,273 ms
74,188 KB |
testcase_26 | AC | 1,319 ms
74,000 KB |
testcase_27 | AC | 1,271 ms
80,760 KB |
testcase_28 | AC | 1,356 ms
82,852 KB |
testcase_29 | AC | 1,379 ms
81,600 KB |
testcase_30 | AC | 1,195 ms
80,636 KB |
testcase_31 | AC | 1,300 ms
80,368 KB |
testcase_32 | AC | 1,361 ms
81,864 KB |
testcase_33 | AC | 1,224 ms
82,712 KB |
testcase_34 | AC | 1,325 ms
81,056 KB |
testcase_35 | AC | 1,259 ms
81,628 KB |
testcase_36 | AC | 1,274 ms
81,572 KB |
testcase_37 | AC | 1,029 ms
89,708 KB |
testcase_38 | AC | 1,239 ms
84,240 KB |
testcase_39 | AC | 1,214 ms
85,992 KB |
testcase_40 | AC | 1,227 ms
87,216 KB |
testcase_41 | AC | 1,045 ms
85,888 KB |
testcase_42 | AC | 1,027 ms
85,740 KB |
testcase_43 | AC | 1,256 ms
79,044 KB |
testcase_44 | AC | 1,012 ms
72,832 KB |
testcase_45 | AC | 867 ms
86,360 KB |
ソースコード
package yukicoder; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.Scanner; public class Q449 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n]; for (int i = 0; i < n; ++i) { l[i] = sc.nextInt(); } int t = sc.nextInt(); int[] rank = new int[n]; HashMap<String, Integer> map = new HashMap<>(); int count = 0; String[] name = new String[t]; char[] p = new char[t]; int[] scores = new int[t]; HashMap<String, Integer> curScore = new HashMap<>(); for (int i = 0; i < t; ++i) { name[i] = sc.next(); p[i] = sc.next().toCharArray()[0]; if (p[i] == '?') { scores[i] = Integer.MAX_VALUE / 10; } else { int star = l[p[i] - 'A']; if (!map.containsKey(name)) { map.put(name[i], count++); } ++rank[p[i] - 'A']; if (curScore.containsKey(name[i])) { scores[i] += curScore.get(name[i]); } scores[i] += score(map.get(name[i]), rank[p[i] - 'A'], star); curScore.put(name[i], scores[i]); } } int[][] ord = new int[t][]; for (int i = 0; i < t; ++i) { ord[i] = new int[] { i, scores[i] }; } Arrays.sort(ord, new Comparator<int[]>() { @Override public int compare(int[] arg0, int[] arg1) { if (arg0[1] != arg1[1]) return Integer.compare(arg0[1], arg1[1]); else return -Integer.compare(arg0[0], arg1[0]); } }); FenwickTree ft = new FenwickTree(t + 1); for (int i = 0; i < t; ++i) { scores[ord[i][0]] = i + 1; } curScore.clear(); for (int i = 0; i < t; ++i) { if (p[i] == '?') { System.out.println(ft.sum(t) - ft.sum(curScore.get(name[i])) + 1); } else { if (curScore.containsKey(name[i])) { ft.add(curScore.get(name[i]), -1); } ft.add(scores[i], 1); curScore.put(name[i], scores[i]); } } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } static class FenwickTree { int n; int[] dat; public FenwickTree(int n) { this.n = n + 1; dat = new int[this.n]; } void add(int k, int val) { while (k < n) { dat[k] += val; k += k & -k; } } int sum(int k) { int sum = 0; while (k > 0) { sum += dat[k]; k -= k & -k; } return sum; } } static int score(int id, int rank, int star) { return (int) (50 * star + (50 * star) / (0.8 + 0.2 * rank)); } }