結果

問題 No.723 2つの数の和
ユーザー masamasa
提出日時 2019-01-16 16:27:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 465 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 71,744 KB
実行使用メモリ 66,036 KB
最終ジャッジ日時 2023-09-10 18:12:51
合計ジャッジ時間 13,024 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
59,428 KB
testcase_01 AC 121 ms
59,772 KB
testcase_02 AC 121 ms
60,144 KB
testcase_03 AC 455 ms
64,148 KB
testcase_04 AC 513 ms
64,576 KB
testcase_05 AC 466 ms
64,276 KB
testcase_06 AC 499 ms
64,360 KB
testcase_07 AC 367 ms
64,760 KB
testcase_08 AC 403 ms
64,112 KB
testcase_09 AC 481 ms
64,720 KB
testcase_10 AC 386 ms
64,260 KB
testcase_11 AC 246 ms
63,308 KB
testcase_12 AC 395 ms
64,352 KB
testcase_13 AC 497 ms
65,132 KB
testcase_14 AC 317 ms
66,036 KB
testcase_15 AC 394 ms
64,360 KB
testcase_16 AC 427 ms
64,352 KB
testcase_17 AC 488 ms
64,540 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 120 ms
59,688 KB
testcase_21 AC 121 ms
60,276 KB
testcase_22 AC 120 ms
58,180 KB
testcase_23 AC 555 ms
64,656 KB
testcase_24 AC 330 ms
64,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n   = sc.nextInt();
		int x   = sc.nextInt();
		int a[] = new int[n];
		int t[] = new int[1000001];
		int ans = 0;
		
		for (int i = 0; i < n; i++) {
		    a[i] = sc.nextInt();
		    t[a[i]]++;
		}
		
		for (int i = 0; i < n; i++) {
		    if (x - a[i] >= 0 && x - a[i] <= 1000000) ans += t[x - a[i]];
		}
		
		System.out.println(ans);
	}
}
0