結果

問題 No.332 数列をプレゼントに
ユーザー nebukuro09nebukuro09
提出日時 2017-03-17 22:52:29
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 1,152 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 103,352 KB
実行使用メモリ 70,172 KB
最終ジャッジ日時 2023-09-03 12:30:14
合計ジャッジ時間 3,883 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 22 ms
7,464 KB
testcase_07 AC 243 ms
51,500 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 8 ms
4,404 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 3 ms
4,384 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 5 ms
5,132 KB
testcase_22 AC 4 ms
4,384 KB
testcase_23 AC 191 ms
68,652 KB
testcase_24 AC 244 ms
70,172 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 62 ms
26,196 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 14 ms
6,004 KB
testcase_30 AC 61 ms
23,204 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 17 ms
8,012 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 3 ms
4,384 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 3 ms
4,380 KB
testcase_46 AC 4 ms
4,376 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;
    dp1[0] = [];
    dp2[0] = [];

    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";
            }
            break;
        }
    }

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