結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2023-08-22 10:51:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 63 ms / 5,000 ms |
コード長 | 457 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 62,976 KB |
最終ジャッジ日時 | 2024-12-16 07:01:15 |
合計ジャッジ時間 | 2,686 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
N = int(input()) W = list(map(int, input().split())) total = sum(W) if total % 2 == 1: print('impossible') exit() half = total // 2 dp = [[False]*(half+1) for _ in range(N+1)] dp[0][0] = True for i in range(N): for j in range(half+1): if not dp[i][j]: continue dp[i+1][j] = True if j + W[i] <= half: dp[i+1][j+W[i]] = True if dp[N][half]: print('possible') else: print('impossible')