結果

問題 No.4 おもりと天秤
ユーザー nsd_fbnsd_fb
提出日時 2015-02-19 03:50:50
言語 Python2
(2.7.18)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 338 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,200 KB
最終ジャッジ日時 2023-09-08 16:08:47
合計ジャッジ時間 1,683 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,080 KB
testcase_01 AC 12 ms
5,952 KB
testcase_02 AC 13 ms
6,024 KB
testcase_03 AC 13 ms
5,952 KB
testcase_04 AC 13 ms
5,940 KB
testcase_05 AC 52 ms
6,080 KB
testcase_06 AC 12 ms
6,072 KB
testcase_07 AC 52 ms
6,148 KB
testcase_08 AC 11 ms
6,072 KB
testcase_09 AC 90 ms
6,200 KB
testcase_10 AC 58 ms
6,044 KB
testcase_11 AC 12 ms
6,008 KB
testcase_12 AC 11 ms
6,124 KB
testcase_13 AC 11 ms
6,068 KB
testcase_14 AC 11 ms
6,040 KB
testcase_15 AC 11 ms
6,056 KB
testcase_16 AC 12 ms
6,052 KB
testcase_17 AC 11 ms
6,072 KB
testcase_18 AC 51 ms
6,056 KB
testcase_19 AC 48 ms
5,976 KB
testcase_20 AC 47 ms
6,164 KB
testcase_21 AC 45 ms
6,076 KB
testcase_22 AC 46 ms
6,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N = input()
    W = map(int, raw_input().split())

    S = sum(W)

    if S & 1:
        return False

    can = [False] * (S + 1)
    can[0] = True

    for w in W:
        for i in xrange(S - w, -1, -1):
            can[i + w] = can[i + w] or can[i]

    return can[S / 2]

print 'possible' if solve() else 'impossible'
0