結果

問題 No.4 おもりと天秤
ユーザー qib
提出日時 2022-10-21 21:48:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 316 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 78,288 KB
最終ジャッジ日時 2024-07-01 06:24:14
合計ジャッジ時間 2,815 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

_ = input()
w = list(map(int, input().split()))

dp = defaultdict(int)
dp[w.pop()] += 1
for i in range(len(w)):
  ndp = defaultdict(int)
  for x, v in dp.items():
  	ndp[x + w[i]] += v
  	ndp[x - w[i]] += v
  dp = ndp

if dp[0] > 0:
  print("possible")
else:
	print("impossible")
0