結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-14 21:09:53 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 5,000 ms |
| + 182µs | |
| コード長 | 514 bytes |
| 記録 | |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 95,396 KB |
| 実行使用メモリ | 82,944 KB |
| 最終ジャッジ日時 | 2026-07-27 14:09:55 |
| 合計ジャッジ時間 | 3,431 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
def balance(weights: list) -> str:
total_weight = sum(weights)
if total_weight % 2 != 0:
return "impossible"
half_weight = total_weight // 2
possible = [False] * (half_weight + 1)
possible[0] = True
for weight in weights:
for i in range(half_weight, weight - 1, -1):
if possible[i - weight]:
possible[i] = True
return "possible" if possible[half_weight] else "impossible"
N = int(input())
W = list(map(int, input().split()))
print(balance(W))