結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2022-01-22 15:11:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 46 ms / 5,000 ms |
コード長 | 323 bytes |
コンパイル時間 | 391 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 59,904 KB |
最終ジャッジ日時 | 2024-11-27 12:19:14 |
合計ジャッジ時間 | 2,287 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
N = int(input()) W = list(map(int, input().split())) sumW = sum(W) if sumW & 1: print("impossible") exit() s2 = sumW //2 dp = [False] * (s2 + 1) dp[0] = True for w in W: for i in range(s2+1)[::-1]: if i-w < 0: break dp[i] |= dp[i-w] print("possible" if dp[s2] else "impossible")