結果

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

ソースコード

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 reversed(range(sumhalf)):
        if DP[i] == 1:
            DP[i + w] = 1

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