結果

問題 No.4 おもりと天秤
ユーザー nak2yoshinak2yoshi
提出日時 2020-11-07 01:21:59
言語 D
(dmd 2.106.1)
結果
RE  
実行時間 -
コード長 512 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 162,024 KB
実行使用メモリ 5,032 KB
最終ジャッジ日時 2023-09-04 10:56:23
合計ジャッジ時間 2,964 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,524 KB
testcase_01 AC 2 ms
4,516 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,556 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 3 ms
4,468 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 2 ms
4,532 KB
testcase_16 RE -
testcase_17 AC 2 ms
4,468 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;
import core.bitop;

void main()
{
    auto N = readln.strip.to!int;
    auto W = readln.split.to!(int[]);

    bool[100][10001] memo;
    bool solve(int i, int left, int right)
    {
        if (i == N)
            return left == right;

        if (memo[i][left])
            return false;

        memo[i][left] = true;

        return solve(i + 1, left + W[i], right       )
            || solve(i + 1, left,        right + W[i]);
    }
    (solve(0, 0, 0) ? "possible" : "impossible").writeln;
}
0