結果

問題 No.723 2つの数の和
ユーザー 37zigen37zigen
提出日時 2018-08-03 22:47:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 3,238 ms
コンパイル使用メモリ 77,056 KB
実行使用メモリ 66,380 KB
最終ジャッジ日時 2023-10-19 21:32:20
合計ジャッジ時間 13,199 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
61,268 KB
testcase_01 AC 141 ms
61,532 KB
testcase_02 AC 140 ms
61,248 KB
testcase_03 AC 496 ms
66,216 KB
testcase_04 AC 574 ms
66,264 KB
testcase_05 AC 527 ms
66,208 KB
testcase_06 AC 560 ms
66,348 KB
testcase_07 AC 412 ms
66,064 KB
testcase_08 AC 422 ms
66,124 KB
testcase_09 AC 536 ms
66,224 KB
testcase_10 AC 423 ms
66,016 KB
testcase_11 AC 262 ms
64,780 KB
testcase_12 AC 451 ms
66,220 KB
testcase_13 AC 555 ms
66,164 KB
testcase_14 AC 341 ms
65,924 KB
testcase_15 AC 431 ms
66,168 KB
testcase_16 AC 475 ms
66,188 KB
testcase_17 AC 552 ms
66,352 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 141 ms
61,308 KB
testcase_21 AC 140 ms
61,548 KB
testcase_22 AC 142 ms
61,260 KB
testcase_23 AC 552 ms
66,172 KB
testcase_24 AC 366 ms
65,880 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 || x - a[i] >= cnt.length)
				continue;
			ans += cnt[x - a[i]];
		}
		System.out.println(ans);
	}
}
0