結果

問題 No.723 2つの数の和
ユーザー YamaKasaYamaKasa
提出日時 2018-08-04 12:31:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 590 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 74,860 KB
実行使用メモリ 62,224 KB
最終ジャッジ日時 2023-10-19 21:48:46
合計ジャッジ時間 13,040 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
55,604 KB
testcase_01 AC 136 ms
57,688 KB
testcase_02 AC 138 ms
57,588 KB
testcase_03 AC 488 ms
61,924 KB
testcase_04 AC 525 ms
62,072 KB
testcase_05 AC 523 ms
62,128 KB
testcase_06 AC 562 ms
62,224 KB
testcase_07 AC 411 ms
61,836 KB
testcase_08 AC 423 ms
61,972 KB
testcase_09 AC 536 ms
62,076 KB
testcase_10 AC 415 ms
61,844 KB
testcase_11 AC 262 ms
61,096 KB
testcase_12 AC 441 ms
62,064 KB
testcase_13 AC 555 ms
62,140 KB
testcase_14 AC 352 ms
61,812 KB
testcase_15 AC 452 ms
62,112 KB
testcase_16 AC 489 ms
62,072 KB
testcase_17 AC 509 ms
62,052 KB
testcase_18 AC 496 ms
61,852 KB
testcase_19 AC 590 ms
62,212 KB
testcase_20 AC 143 ms
57,520 KB
testcase_21 AC 142 ms
57,192 KB
testcase_22 AC 143 ms
55,664 KB
testcase_23 AC 544 ms
62,116 KB
testcase_24 AC 372 ms
61,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int X = scan.nextInt();
		int l = 100001;
		long []a = new long[l];

		for(int i = 0; i < N; i++) {
			a[scan.nextInt()] ++;
		}
		scan.close();
		long ans = 0;
		for(int i = 0; i < l; i++) {
			int res = X - i;
			if(res >= 0 && res <= 100000) {
				ans += a[i] * a[res];
			}
		}
		System.out.println(ans);
	}
}
0