結果

問題 No.723 2つの数の和
コンテスト
ユーザー ryosuke0825
提出日時 2018-09-15 13:45:58
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 541 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,543 ms
コンパイル使用メモリ 83,052 KB
実行使用メモリ 134,756 KB
最終ジャッジ日時 2026-04-01 14:57:12
合計ジャッジ時間 8,940 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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