結果

問題 No.4 おもりと天秤
ユーザー rlangevin
提出日時 2023-01-25 00:04:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 221 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,016 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-06-26 08:31:45
合計ジャッジ時間 1,961 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int, input().split()))
S = sum(W)
if S % 2:
    print("impossible")
    exit()

dp = 1
for i in range(N):
    dp |= (dp << W[i])
print("possible") if (dp >> (S//2))&1 else print("impossible")
0