結果

問題 No.723 2つの数の和
ユーザー ryosuke0825
提出日時 2018-09-15 13:45:58
言語 Java
(openjdk 23)
結果
AC  
実行時間 608 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 2,996 ms
コンパイル使用メモリ 74,764 KB
実行使用メモリ 59,864 KB
最終ジャッジ日時 2024-07-17 23:47:07
合計ジャッジ時間 13,965 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No723 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String nx = sc.nextLine();
		String[] nxArr = nx.split(" ");
		int N = Integer.parseInt(nxArr[0]);
		int X = Integer.parseInt(nxArr[1]);

		int a[]=new int[100000];
		int t[] = new int[100001];
		int i;
		for(i=0;i<N;i++) {
			a[i]=sc.nextInt();
			t[a[i]]++;
		}
		sc.close();
		long s=0;
		for(i=0;i<N;i++) {
			if(X-a[i]>=0 && 100000 >= X-a[i]) {
				s +=t[X-a[i]];
			}
		}
		System.out.println(s);

	}

}
0