結果

問題 No.4 おもりと天秤
コンテスト
ユーザー HIROPON87069639
提出日時 2016-03-09 21:49:38
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 383 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 140 ms
コンパイル使用メモリ 77,608 KB
最終ジャッジ日時 2025-12-03 19:38:36
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- 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