結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-21 21:48:14 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 5,000 ms |
| コード長 | 316 bytes |
| 記録 | |
| コンパイル時間 | 336 ms |
| コンパイル使用メモリ | 84,996 KB |
| 実行使用メモリ | 83,316 KB |
| 最終ジャッジ日時 | 2026-03-22 01:44:52 |
| 合計ジャッジ時間 | 2,197 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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")