結果

問題 No.332 数列をプレゼントに
コンテスト
ユーザー nebukuro09
提出日時 2017-03-17 22:19:52
言語 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  
実行時間 -
コード長 787 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 900 ms
コンパイル使用メモリ 105,456 KB
実行使用メモリ 1,012,928 KB
最終ジャッジ日時 2026-03-05 13:53:13
合計ジャッジ時間 26,102 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 MLE * 2
other AC * 17 WA * 16 TLE * 5 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;
    A.sort();

    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