結果
問題 | No.1708 Quality of Contest |
ユーザー | tenten |
提出日時 | 2023-02-22 12:57:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,288 ms / 2,000 ms |
コード長 | 2,450 bytes |
コンパイル時間 | 3,418 ms |
コンパイル使用メモリ | 95,136 KB |
実行使用メモリ | 96,492 KB |
最終ジャッジ日時 | 2023-09-29 21:02:56 |
合計ジャッジ時間 | 27,186 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
33,756 KB |
testcase_01 | AC | 40 ms
33,760 KB |
testcase_02 | AC | 44 ms
34,224 KB |
testcase_03 | AC | 139 ms
38,432 KB |
testcase_04 | AC | 153 ms
39,092 KB |
testcase_05 | AC | 145 ms
38,272 KB |
testcase_06 | AC | 143 ms
37,960 KB |
testcase_07 | AC | 142 ms
37,772 KB |
testcase_08 | AC | 39 ms
33,764 KB |
testcase_09 | AC | 1,079 ms
92,672 KB |
testcase_10 | AC | 804 ms
69,900 KB |
testcase_11 | AC | 1,015 ms
65,656 KB |
testcase_12 | AC | 1,121 ms
65,812 KB |
testcase_13 | AC | 1,069 ms
78,204 KB |
testcase_14 | AC | 1,127 ms
67,724 KB |
testcase_15 | AC | 1,288 ms
96,492 KB |
testcase_16 | AC | 1,235 ms
95,936 KB |
testcase_17 | AC | 1,123 ms
78,688 KB |
testcase_18 | AC | 1,214 ms
88,560 KB |
testcase_19 | AC | 1,277 ms
90,444 KB |
testcase_20 | AC | 1,093 ms
81,724 KB |
testcase_21 | AC | 1,104 ms
79,600 KB |
testcase_22 | AC | 1,102 ms
81,396 KB |
testcase_23 | AC | 1,194 ms
85,224 KB |
testcase_24 | AC | 900 ms
70,128 KB |
testcase_25 | AC | 822 ms
68,036 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int x = sc.nextInt(); HashMap<Integer, ArrayList<Integer>> questions = new HashMap<>(); for (int i = 0; i < n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); if (!questions.containsKey(b)) { questions.put(b, new ArrayList<>()); } questions.get(b).add(a); } ArrayList<Integer> total = new ArrayList<>(); for (ArrayList<Integer> list : questions.values()) { Collections.sort(list); list.add(list.remove(list.size() - 1) + x); total.addAll(list); } Collections.sort(total); long[] sums = new long[n + 1]; for (int i = 1; i <= n; i++) { sums[i] = sums[i - 1] + total.get(total.size() - i); } int k = sc.nextInt(); long ans = 0; for (int i = 0; i < k; i++) { ans += sums[sc.nextInt()]; } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } 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 int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }