結果

問題 No.4 おもりと天秤
コンテスト
ユーザー MitI_7
提出日時 2015-12-24 20:10:50
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 441 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 289 ms
コンパイル使用メモリ 21,284 KB
実行使用メモリ 15,868 KB
最終ジャッジ日時 2026-08-30 13:18:10
合計ジャッジ時間 4,187 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    n = input()
    w = list(map(int, input().split()))
    s = sum(w)
    if s % 2 != 0:
        print("impossible")
    else:
        l = [0 for i in range(s // 2 + 1)]
        l[0] = 1
        for x in w:
            for y in range(len(l)):
                if l[y] != 0 and y + x < len(l):
                    l[y + x] = 1

        print("possible" if l[s // 2] else "impossible")

    
if __name__ == '__main__':
    main()
0