結果

問題 No.4 おもりと天秤
ユーザー AtamaokaC
提出日時 2021-06-19 17:29:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 379 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 72,064 KB
最終ジャッジ日時 2024-06-22 22:11:53
合計ジャッジ時間 1,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

inpl = lambda: list(map(int,input().split()))
N = int(input())
W = inpl()
S = sum(W)
if S % 2:
    print('impossible')
    exit()
else:
    T = S//2
cur = {0}
for w in W:
    new = set()
    for c in cur:
        n = c + w
        if n == T:
            print('possible')
            exit()
        elif n < T:
            new.add(n)
    cur |= new
else:
    print('impossible')
0