結果

問題 No.4 おもりと天秤
コンテスト
ユーザー るさ
提出日時 2018-06-03 17:35:32
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 225 ms / 5,000 ms
コード長 477 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 585 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2026-03-20 05:53:19
合計ジャッジ時間 4,577 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from copy import copy
n=int(input())
w=list(map(int,input().split()))
hw=int(sum(w)/2)
if hw*2!=sum(w):
    print("impossible")
else:
    table=[0 for i in range(hw+1)]
    table[0]=1
    for i in w:
        ntable=copy(table)
        for j in range(hw+1):
            try:
                ntable[j+i]=max(table[j+i],table[j])
            except:
                pass
        table=copy(ntable)
    if table[-1]==1:
       print("possible")
    else:
       print("impossible")
0