結果

問題 No.332 数列をプレゼントに
コンテスト
ユーザー nebukuro09
提出日時 2017-03-17 22:15:47
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
MLE  
実行時間 -
コード長 773 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 830 ms
コンパイル使用メモリ 101,744 KB
実行使用メモリ 746,884 KB
最終ジャッジ日時 2026-03-05 13:52:36
合計ジャッジ時間 25,205 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1 MLE * 3
other AC * 18 WA * 14 TLE * 6 MLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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