結果

問題 No.723 2つの数の和
ユーザー 37zigen37zigen
提出日時 2018-08-03 22:46:19
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 489 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 74,032 KB
実行使用メモリ 66,484 KB
最終ジャッジ日時 2023-10-19 21:31:58
合計ジャッジ時間 12,635 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
61,068 KB
testcase_01 AC 134 ms
61,268 KB
testcase_02 AC 132 ms
61,676 KB
testcase_03 AC 484 ms
66,060 KB
testcase_04 AC 516 ms
66,056 KB
testcase_05 AC 506 ms
65,928 KB
testcase_06 AC 539 ms
66,312 KB
testcase_07 AC 402 ms
66,008 KB
testcase_08 AC 430 ms
66,256 KB
testcase_09 AC 527 ms
66,064 KB
testcase_10 AC 408 ms
65,896 KB
testcase_11 AC 248 ms
64,632 KB
testcase_12 AC 435 ms
66,152 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 133 ms
61,276 KB
testcase_21 AC 122 ms
60,252 KB
testcase_22 AC 133 ms
61,572 KB
testcase_23 AC 534 ms
65,956 KB
testcase_24 AC 356 ms
65,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int[] cnt = new int[1000001];
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			cnt[a[i]]++;
		}
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			if (x - a[i] < 0)
				continue;
			ans += cnt[x - a[i]];
		}
		System.out.println(ans);
	}
}
0