結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 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 |
ソースコード
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")