結果

問題 No.4 おもりと天秤
ユーザー tjaketjake
提出日時 2015-12-06 02:48:01
言語 Python2
(2.7.18)
結果
AC  
実行時間 179 ms / 5,000 ms
コード長 217 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 6,528 KB
実行使用メモリ 6,204 KB
最終ジャッジ日時 2023-09-08 16:29:07
合計ジャッジ時間 2,286 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,068 KB
testcase_01 AC 12 ms
6,068 KB
testcase_02 AC 14 ms
6,168 KB
testcase_03 AC 12 ms
6,048 KB
testcase_04 AC 13 ms
6,000 KB
testcase_05 AC 101 ms
6,008 KB
testcase_06 AC 12 ms
6,124 KB
testcase_07 AC 101 ms
6,016 KB
testcase_08 AC 13 ms
5,992 KB
testcase_09 AC 179 ms
6,148 KB
testcase_10 AC 113 ms
6,204 KB
testcase_11 AC 13 ms
5,964 KB
testcase_12 AC 12 ms
6,112 KB
testcase_13 AC 12 ms
6,056 KB
testcase_14 AC 12 ms
5,968 KB
testcase_15 AC 12 ms
5,972 KB
testcase_16 AC 12 ms
5,952 KB
testcase_17 AC 12 ms
6,044 KB
testcase_18 AC 99 ms
6,096 KB
testcase_19 AC 92 ms
6,148 KB
testcase_20 AC 91 ms
6,160 KB
testcase_21 AC 87 ms
6,144 KB
testcase_22 AC 88 ms
6,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input()
w = map(int, raw_input().split())
s = sum(w)

dp = [0]*(s+1)
dp[0] = 1
for i in xrange(n):
    for j in xrange(s,w[i]-1,-1):
        dp[j] |= dp[j-w[i]]
print "impossible"*(s%2 or dp[s/2]^1) or "possible"
0