結果

問題 No.723 2つの数の和
ユーザー Pump0129Pump0129
提出日時 2018-11-28 00:26:50
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,070 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 71,500 KB
実行使用メモリ 69,216 KB
最終ジャッジ日時 2023-09-07 02:42:56
合計ジャッジ時間 8,807 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
60,300 KB
testcase_01 AC 132 ms
55,960 KB
testcase_02 AC 130 ms
53,796 KB
testcase_03 AC 1,412 ms
64,976 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.No723;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int num_len = scan.nextInt();
        int base_num = scan.nextInt();

        int[] num_array = new int[num_len];

        int ans_cnt = 0;

        for (int i = 0; i < num_len; i++) {
            int a = scan.nextInt();
            num_array[i] = a;
        }

        Arrays.sort(num_array);

        for (int i = 0; i < num_len; i++) {
            int sub = base_num - num_array[i];
            if (num_array[i] <= base_num) {
                for (int j = i; j < num_len; j++) {
                    if (sub == num_array[j]) {
                        if (i == j) ans_cnt += 1;
                        else ans_cnt += 2;
                    } else if (sub < num_array[j]) {
                        break;
                    }
                }
            }
        }

        System.out.println(ans_cnt);
    }
}
0