結果

問題 No.723 2つの数の和
ユーザー ryosuke0825ryosuke0825
提出日時 2018-09-15 13:45:58
言語 Java19
(openjdk 21)
結果
AC  
実行時間 552 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 3,119 ms
コンパイル使用メモリ 72,392 KB
実行使用メモリ 47,284 KB
最終ジャッジ日時 2023-09-24 23:27:14
合計ジャッジ時間 13,933 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
40,340 KB
testcase_01 AC 123 ms
39,900 KB
testcase_02 AC 122 ms
40,372 KB
testcase_03 AC 471 ms
46,740 KB
testcase_04 AC 530 ms
46,884 KB
testcase_05 AC 502 ms
46,584 KB
testcase_06 AC 549 ms
47,016 KB
testcase_07 AC 381 ms
46,868 KB
testcase_08 AC 435 ms
46,804 KB
testcase_09 AC 540 ms
46,644 KB
testcase_10 AC 399 ms
46,464 KB
testcase_11 AC 240 ms
45,380 KB
testcase_12 AC 427 ms
46,856 KB
testcase_13 AC 538 ms
46,688 KB
testcase_14 AC 324 ms
46,508 KB
testcase_15 AC 412 ms
46,784 KB
testcase_16 AC 452 ms
47,284 KB
testcase_17 AC 522 ms
46,944 KB
testcase_18 AC 480 ms
46,908 KB
testcase_19 AC 552 ms
46,864 KB
testcase_20 AC 121 ms
40,628 KB
testcase_21 AC 120 ms
40,112 KB
testcase_22 AC 124 ms
40,520 KB
testcase_23 AC 518 ms
46,548 KB
testcase_24 AC 347 ms
47,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No723 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String nx = sc.nextLine();
		String[] nxArr = nx.split(" ");
		int N = Integer.parseInt(nxArr[0]);
		int X = Integer.parseInt(nxArr[1]);

		int a[]=new int[100000];
		int t[] = new int[100001];
		int i;
		for(i=0;i<N;i++) {
			a[i]=sc.nextInt();
			t[a[i]]++;
		}
		sc.close();
		long s=0;
		for(i=0;i<N;i++) {
			if(X-a[i]>=0 && 100000 >= X-a[i]) {
				s +=t[X-a[i]];
			}
		}
		System.out.println(s);

	}

}
0