結果

問題 No.4 おもりと天秤
ユーザー HIROPON87069639HIROPON87069639
提出日時 2016-03-09 21:49:38
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 383 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 7,088 KB
実行使用メモリ 6,672 KB
最終ジャッジ日時 2023-10-24 21:56:28
合計ジャッジ時間 1,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,488 KB
testcase_01 AC 12 ms
6,488 KB
testcase_02 AC 12 ms
6,492 KB
testcase_03 AC 11 ms
6,488 KB
testcase_04 AC 13 ms
6,496 KB
testcase_05 AC 55 ms
6,580 KB
testcase_06 AC 11 ms
6,488 KB
testcase_07 AC 55 ms
6,580 KB
testcase_08 AC 11 ms
6,488 KB
testcase_09 AC 54 ms
6,672 KB
testcase_10 AC 60 ms
6,596 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 11 ms
6,488 KB
testcase_14 WA -
testcase_15 AC 12 ms
6,488 KB
testcase_16 AC 11 ms
6,488 KB
testcase_17 AC 11 ms
6,488 KB
testcase_18 AC 43 ms
6,576 KB
testcase_19 AC 51 ms
6,572 KB
testcase_20 AC 50 ms
6,568 KB
testcase_21 AC 48 ms
6,564 KB
testcase_22 AC 49 ms
6,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
#input
N = input()
W = map(int, raw_input().split())
if sum(W) % 2 == 1:
    print "impossible"
    exit()
sumhalf = sum(W) / 2

# dynamic programming
DP = [0] * (sumhalf + 100)
DP[0] = 1
for w in W:
    for i in range(sumhalf):
        if DP[i] == 1:
            DP[i + w] = 1

# output
if DP[sumhalf] == 1:
    print "possible"
else:
    print "impossible"
0