結果

問題 No.4 おもりと天秤
ユーザー yuki2006yuki2006
提出日時 2014-10-03 12:58:37
言語 Python2
(2.7.18)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 365 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 6,624 KB
実行使用メモリ 6,608 KB
最終ジャッジ日時 2023-09-08 16:01:50
合計ジャッジ時間 2,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,564 KB
testcase_01 AC 12 ms
6,424 KB
testcase_02 AC 12 ms
6,528 KB
testcase_03 AC 12 ms
6,508 KB
testcase_04 AC 12 ms
6,416 KB
testcase_05 AC 32 ms
6,552 KB
testcase_06 AC 12 ms
6,536 KB
testcase_07 AC 32 ms
6,424 KB
testcase_08 AC 12 ms
6,468 KB
testcase_09 AC 50 ms
6,468 KB
testcase_10 AC 35 ms
6,516 KB
testcase_11 AC 12 ms
6,600 KB
testcase_12 AC 11 ms
6,412 KB
testcase_13 AC 11 ms
6,524 KB
testcase_14 AC 12 ms
6,416 KB
testcase_15 AC 12 ms
6,588 KB
testcase_16 AC 12 ms
6,608 KB
testcase_17 AC 11 ms
6,420 KB
testcase_18 AC 31 ms
6,428 KB
testcase_19 AC 31 ms
6,564 KB
testcase_20 AC 30 ms
6,428 KB
testcase_21 AC 29 ms
6,424 KB
testcase_22 AC 29 ms
6,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(data):
    dp = [False] * 100000
    dp[0] = True
    if sum(data) % 2 != 0:
        return False

    total = sum(data) / 2

    for v in data:
        for t in xrange(total, v - 1, -1):
            dp[t] |= dp[t - v]

    return dp[total]


N = int(raw_input())
data = map(int, raw_input().split(" "))

print "possible" if solve(data) else "impossible"
0