結果

問題 No.332 数列をプレゼントに
ユーザー nebukuro09nebukuro09
提出日時 2017-03-17 22:15:47
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 773 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 105,172 KB
実行使用メモリ 284,524 KB
最終ジャッジ日時 2023-09-03 12:28:56
合計ジャッジ時間 6,277 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,764 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 199 ms
28,092 KB
testcase_07 MLE -
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 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split;
    auto N = s[0].to!int;
    auto X = s[1].to!long;
    auto A = readln.split.map!(to!long).array;

    int[][long] dp;
    foreach (i; 0..N) {
        foreach (k; dp.keys) {
            if (A[i]+k <= X && !(A[i]+k in dp))
                dp[A[i]+k] = (dp[k] ~ i);
        }
        if (A[i] <= X && !(A[i] in dp)) dp[A[i]] = [i];
    }

    string ans = "";
    if (X in dp) {
        foreach (i; 0..N) {
            ans ~= (find(dp[X], i).empty) ? "x" : "o";
        }
    }
    else {
        ans = "NO";
    }

    ans.writeln;
}
0