結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2025-03-31 17:30:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 47 ms / 5,000 ms |
コード長 | 376 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 82,660 KB |
実行使用メモリ | 60,096 KB |
最終ジャッジ日時 | 2025-03-31 17:31:22 |
合計ジャッジ時間 | 1,913 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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")