結果

問題 No.723 2つの数の和
ユーザー kokatsukokatsu
提出日時 2021-10-11 00:15:00
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 492 bytes
コンパイル時間 2,656 ms
コンパイル使用メモリ 208,732 KB
実行使用メモリ 8,056 KB
最終ジャッジ日時 2023-09-04 14:26:43
合計ジャッジ時間 4,617 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 27 ms
6,876 KB
testcase_04 AC 34 ms
7,268 KB
testcase_05 AC 30 ms
6,952 KB
testcase_06 AC 34 ms
7,780 KB
testcase_07 AC 15 ms
4,636 KB
testcase_08 AC 17 ms
4,652 KB
testcase_09 AC 34 ms
6,572 KB
testcase_10 AC 14 ms
4,496 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 20 ms
7,336 KB
testcase_13 AC 34 ms
7,204 KB
testcase_14 AC 8 ms
4,376 KB
testcase_15 AC 15 ms
4,568 KB
testcase_16 AC 22 ms
5,740 KB
testcase_17 AC 28 ms
6,972 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 27 ms
8,056 KB
testcase_24 AC 10 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int N, X;
    readf("%d %d\n", N, X);

    auto a = readln.chomp.split.to!(int[]);

    a.sort;
    auto b = a.assumeSorted;

    int res;
    while (!b.empty) {
        int f = b.front;
        if (b.contains(X-f)) {
            auto l = b.equalRange(X-f).length;
            if (X == 2 * f) {
                res += 2 * l - 1;
            }
            else {
                res += 2 * l;
            }
        }
        b.popFront;
    }

    res.writeln;
}
0