結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-26 15:44:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 5,000 ms |
| コード長 | 376 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 59,264 KB |
| 最終ジャッジ日時 | 2025-03-26 15:44:40 |
| 合計ジャッジ時間 | 1,842 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
n = int(input())
weights = list(map(int, input().split()))
total = sum(weights)
if total % 2 != 0:
print("impossible")
else:
target = total // 2
dp = [False] * (target + 1)
dp[0] = True
for w in weights:
for j in range(target, w - 1, -1):
if dp[j - w]:
dp[j] = True
print("possible" if dp[target] else "impossible")
lam6er