結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2024-06-15 23:38:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 74 ms / 5,000 ms |
コード長 | 376 bytes |
コンパイル時間 | 376 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-15 23:38:36 |
合計ジャッジ時間 | 2,826 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
N = int(input()) W = list(map(int, input().split())) total = sum(W) if total % 2: print('impossible') else: half = total // 2 dp = [0] * (half + 1) dp[0] = 1 for w in W: for i in range(half, w - 1, -1): if dp[i - w]: dp[i] = 1 if dp[half]: print('possible') exit() print('impossible')