結果
問題 | No.723 2つの数の和 |
ユーザー | Pump0129 |
提出日時 | 2018-11-28 00:40:29 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,187 bytes |
コンパイル時間 | 2,950 ms |
コンパイル使用メモリ | 75,520 KB |
実行使用メモリ | 78,332 KB |
最終ジャッジ日時 | 2023-09-07 03:00:24 |
合計ジャッジ時間 | 16,342 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
56,324 KB |
testcase_01 | AC | 119 ms
55,560 KB |
testcase_02 | AC | 121 ms
55,884 KB |
testcase_03 | AC | 614 ms
68,020 KB |
testcase_04 | AC | 762 ms
74,804 KB |
testcase_05 | AC | 715 ms
73,156 KB |
testcase_06 | AC | 741 ms
73,744 KB |
testcase_07 | AC | 458 ms
64,888 KB |
testcase_08 | AC | 509 ms
65,132 KB |
testcase_09 | AC | 744 ms
76,852 KB |
testcase_10 | AC | 493 ms
65,008 KB |
testcase_11 | AC | 262 ms
61,008 KB |
testcase_12 | AC | 532 ms
67,248 KB |
testcase_13 | AC | 784 ms
77,484 KB |
testcase_14 | AC | 378 ms
62,584 KB |
testcase_15 | AC | 510 ms
65,312 KB |
testcase_16 | AC | 574 ms
67,000 KB |
testcase_17 | AC | 705 ms
71,252 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 121 ms
56,192 KB |
testcase_21 | AC | 121 ms
55,912 KB |
testcase_22 | AC | 121 ms
55,768 KB |
testcase_23 | AC | 626 ms
78,332 KB |
testcase_24 | AC | 408 ms
62,672 KB |
ソースコード
package net.ipipip0129.yukicoder.No723; import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num_len = scan.nextInt(); int base_num = scan.nextInt(); int[] num_array = new int[num_len]; Map<Integer, List<Integer>> num_map = new HashMap<>(); int ans_cnt = 0; for (int i = 0; i < num_len; i++) { int a = scan.nextInt(); num_array[i] = a; List<Integer> li; if (num_map.containsKey(a)) li = num_map.get(a); else li = new ArrayList<>(); li.add(i); num_map.put(a, li); } Arrays.sort(num_array); for (int i = 0; i < num_len; i++) { int sub = base_num - num_array[i]; if (num_array[i] <= base_num) { if (num_map.containsKey(sub)) { List<Integer> li = num_map.get(sub); ans_cnt += li.size(); } } else { break; } } System.out.println(ans_cnt); } }