結果

問題 No.723 2つの数の和
ユーザー takeya_okino
提出日時 2019-08-04 13:03:32
言語 Java
(openjdk 23)
結果
AC  
実行時間 599 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 79,016 KB
実行使用メモリ 49,024 KB
最終ジャッジ日時 2024-07-08 01:26:37
合計ジャッジ時間 14,547 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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