結果
問題 | No.1708 Quality of Contest |
ユーザー | tenten |
提出日時 | 2021-10-18 16:17:50 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,252 ms / 2,000 ms |
コード長 | 2,302 bytes |
コンパイル時間 | 2,324 ms |
コンパイル使用メモリ | 78,032 KB |
実行使用メモリ | 61,616 KB |
最終ジャッジ日時 | 2024-09-19 11:23:13 |
合計ジャッジ時間 | 24,452 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
36,864 KB |
testcase_01 | AC | 53 ms
36,724 KB |
testcase_02 | AC | 53 ms
36,952 KB |
testcase_03 | AC | 144 ms
40,856 KB |
testcase_04 | AC | 156 ms
40,948 KB |
testcase_05 | AC | 149 ms
41,076 KB |
testcase_06 | AC | 137 ms
40,680 KB |
testcase_07 | AC | 129 ms
40,408 KB |
testcase_08 | AC | 53 ms
37,068 KB |
testcase_09 | AC | 735 ms
58,496 KB |
testcase_10 | AC | 725 ms
56,876 KB |
testcase_11 | AC | 1,159 ms
57,580 KB |
testcase_12 | AC | 1,113 ms
61,396 KB |
testcase_13 | AC | 1,135 ms
58,424 KB |
testcase_14 | AC | 1,065 ms
61,532 KB |
testcase_15 | AC | 1,144 ms
61,616 KB |
testcase_16 | AC | 1,175 ms
58,344 KB |
testcase_17 | AC | 1,179 ms
57,212 KB |
testcase_18 | AC | 1,192 ms
58,316 KB |
testcase_19 | AC | 1,252 ms
57,168 KB |
testcase_20 | AC | 1,232 ms
57,936 KB |
testcase_21 | AC | 1,143 ms
57,724 KB |
testcase_22 | AC | 1,165 ms
58,740 KB |
testcase_23 | AC | 1,102 ms
58,536 KB |
testcase_24 | AC | 1,045 ms
58,180 KB |
testcase_25 | AC | 1,026 ms
58,944 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 m = sc.nextInt(); int x = sc.nextInt(); Question[] questions = new Question[n]; for (int i = 0; i < n; i++) { questions[i] = new Question(sc.nextInt(), sc.nextInt()); } Arrays.sort(questions, new Comparator<Question>() { public int compare(Question q1, Question q2) { if (q1.type == q2.type) { return q2.value - q1.value; } else { return q1.type - q2.type; } } }); int prev = 0; for (Question q : questions) { if (q.type != prev) { prev = q.type; q.value += x; } } Arrays.sort(questions, new Comparator<Question>() { public int compare(Question q1, Question q2) { return q2.value - q1.value; } }); long[] sums = new long[n + 1]; for (int i = 0; i < n; i++) { sums[i + 1] = sums[i] + questions[i].value; } long ans = 0; int k = sc.nextInt(); for (int i = 0; i < k; i++) { ans += sums[sc.nextInt()]; } System.out.println(ans); } static class Question { int value; int type; public Question(int value, int type) { this.value = value; this.type = type; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }