結果

問題 No.332 数列をプレゼントに
ユーザー nebukuro09nebukuro09
提出日時 2017-03-17 22:50:38
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,099 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 103,480 KB
実行使用メモリ 69,912 KB
最終ジャッジ日時 2023-09-03 12:30:05
合計ジャッジ時間 7,592 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 367 ms
51,236 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 314 ms
68,912 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 17 ms
6,932 KB
testcase_30 WA -
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 18 ms
9,288 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 3 ms
4,384 KB
testcase_35 AC 3 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
4,380 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,384 KB
testcase_41 AC 1 ms
4,384 KB
testcase_42 AC 2 ms
4,384 KB
testcase_43 AC 2 ms
4,384 KB
testcase_44 WA -
testcase_45 AC 3 ms
4,380 KB
testcase_46 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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] dp1;
    int[][long] dp2;

    foreach (i; 0..N/2) {
        foreach (k; dp1.keys) {
            if (A[i]+k <= X && !(A[i]+k in dp1))
                dp1[A[i]+k] = (dp1[k] ~ i);
        }
        if (A[i] <= X && !(A[i] in dp1)) dp1[A[i]] = [i];
    }
    foreach (i; N/2..N) {
        foreach (k; dp2.keys) {
            if (A[i]+k <= X && !(A[i]+k in dp2))
                dp2[A[i]+k] = (dp2[k] ~ i);
        }
        if (A[i] <= X && !(A[i] in dp2)) dp2[A[i]] = [i];
    }

    string ans = "";
    foreach (k; dp1.keys) {
        if ((X-k) in dp2) {
            foreach (i; 0..N) {
                ans ~= (find(dp1[k], i).empty || find(dp2[X-k], i).empty) ? "x" : "o";
            }
        }
    }

    writeln(ans == "" ? "No" : ans);
}
0