結果

問題 No.4 おもりと天秤
コンテスト
ユーザー goto_isyuku
提出日時 2017-05-28 23:13:00
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
MLE  
実行時間 -
コード長 625 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 292 ms
コンパイル使用メモリ 21,464 KB
実行使用メモリ 926,360 KB
最終ジャッジ日時 2026-09-01 17:55:32
合計ジャッジ時間 9,049 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 MLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = input()

wl = [int(x) for x in input().split()]

if sum(wl) % 2 == 1:
    print("impossible")
else:

    obj_sum = sum(wl) // 2
    
    x = True
    tmp = [[[], 0]]
    cnt = 0

    while x and cnt < len(wl) - 1:
        new_tmp = []

        for t in tmp:
            for i in range(len(wl)):
                if i not in t[0]:
                    new_tmp.append([t[0] + [i], t[1] + wl[i]])
        
        for i in new_tmp:
            if i[1] == obj_sum:
                x = False
                break

        cnt += 1
        tmp = new_tmp

    if x:
        print("impossible")
    else:
        print("possible")
0