結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
60,152 KB
testcase_01 AC 126 ms
59,784 KB
testcase_02 AC 126 ms
59,916 KB
testcase_03 AC 461 ms
64,620 KB
testcase_04 AC 541 ms
64,544 KB
testcase_05 AC 498 ms
64,512 KB
testcase_06 AC 545 ms
64,528 KB
testcase_07 AC 381 ms
64,096 KB
testcase_08 AC 421 ms
64,596 KB
testcase_09 AC 519 ms
64,304 KB
testcase_10 AC 388 ms
64,276 KB
testcase_11 AC 249 ms
63,608 KB
testcase_12 AC 427 ms
66,476 KB
testcase_13 AC 519 ms
64,424 KB
testcase_14 AC 323 ms
64,156 KB
testcase_15 AC 398 ms
64,004 KB
testcase_16 AC 447 ms
64,556 KB
testcase_17 AC 516 ms
64,664 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 126 ms
59,416 KB
testcase_21 AC 126 ms
60,152 KB
testcase_22 AC 127 ms
57,808 KB
testcase_23 AC 513 ms
64,480 KB
testcase_24 AC 353 ms
64,252 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[1000000];
		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