結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-11-28 00:40:29 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,187 bytes |
| コンパイル時間 | 2,060 ms |
| コンパイル使用メモリ | 79,836 KB |
| 実行使用メモリ | 68,176 KB |
| 最終ジャッジ日時 | 2024-06-24 21:41:25 |
| 合計ジャッジ時間 | 15,604 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 2 |
ソースコード
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);
}
}