結果

問題 No.723 2つの数の和
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-04 13:03:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 523 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 2,802 ms
コンパイル使用メモリ 71,348 KB
実行使用メモリ 62,324 KB
最終ジャッジ日時 2023-09-22 09:14:44
合計ジャッジ時間 13,031 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,516 KB
testcase_01 AC 123 ms
56,168 KB
testcase_02 AC 125 ms
55,788 KB
testcase_03 AC 455 ms
60,608 KB
testcase_04 AC 520 ms
60,324 KB
testcase_05 AC 474 ms
60,628 KB
testcase_06 AC 510 ms
60,780 KB
testcase_07 AC 379 ms
60,204 KB
testcase_08 AC 414 ms
60,412 KB
testcase_09 AC 500 ms
60,500 KB
testcase_10 AC 389 ms
60,476 KB
testcase_11 AC 235 ms
59,304 KB
testcase_12 AC 402 ms
60,260 KB
testcase_13 AC 496 ms
60,672 KB
testcase_14 AC 317 ms
60,064 KB
testcase_15 AC 394 ms
60,896 KB
testcase_16 AC 425 ms
60,684 KB
testcase_17 AC 486 ms
60,676 KB
testcase_18 AC 422 ms
60,640 KB
testcase_19 AC 523 ms
58,792 KB
testcase_20 AC 121 ms
56,028 KB
testcase_21 AC 121 ms
55,736 KB
testcase_22 AC 121 ms
55,728 KB
testcase_23 AC 498 ms
62,324 KB
testcase_24 AC 334 ms
60,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] a = new int[n];
    int[] num = new int[100001];
    for(int i = 0; i < n; i++) {
      int t = sc.nextInt();
      a[i] = t;
      num[t]++;
    }
    long ans = 0;
    for(int i = 0; i < n; i++) {
      if(((x - a[i]) >= 0) && ((x - a[i]) <= 100000)) ans += num[x - a[i]];
    }
    System.out.println(ans);
  }
}
0