結果

問題 No.723 2つの数の和
ユーザー 37zigen37zigen
提出日時 2018-08-03 23:13:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 622 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 2,369 ms
コンパイル使用メモリ 73,940 KB
実行使用メモリ 66,348 KB
最終ジャッジ日時 2023-10-19 21:38:27
合計ジャッジ時間 13,912 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
61,272 KB
testcase_01 AC 151 ms
61,292 KB
testcase_02 AC 148 ms
61,292 KB
testcase_03 AC 514 ms
66,160 KB
testcase_04 AC 582 ms
66,260 KB
testcase_05 AC 557 ms
65,956 KB
testcase_06 AC 583 ms
66,344 KB
testcase_07 AC 433 ms
65,856 KB
testcase_08 AC 467 ms
66,348 KB
testcase_09 AC 575 ms
66,120 KB
testcase_10 AC 442 ms
66,092 KB
testcase_11 AC 286 ms
65,036 KB
testcase_12 AC 471 ms
66,164 KB
testcase_13 AC 577 ms
66,092 KB
testcase_14 AC 363 ms
65,836 KB
testcase_15 AC 455 ms
65,952 KB
testcase_16 AC 490 ms
66,024 KB
testcase_17 AC 566 ms
66,256 KB
testcase_18 AC 506 ms
66,032 KB
testcase_19 AC 622 ms
66,272 KB
testcase_20 AC 145 ms
61,776 KB
testcase_21 AC 149 ms
61,284 KB
testcase_22 AC 146 ms
61,652 KB
testcase_23 AC 589 ms
64,240 KB
testcase_24 AC 387 ms
65,920 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]]++;
		}
		long 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