結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2019-11-27 15:01:20 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 314 ms / 5,000 ms |
コード長 | 448 bytes |
コンパイル時間 | 706 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 14,592 KB |
最終ジャッジ日時 | 2024-11-08 09:13:25 |
合計ジャッジ時間 | 3,873 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
N = int(input()) W = tuple(map(int, input().split())) if sum(W) % 2 != 0: print('impossible') exit() target = sum(W) // 2 if max(W) > target: print('impossible') exit() dp = [[False] * (target+1) for i in range(N+1)] dp[0][0] = True for i in range(N): for j in range(target+1): dp[i+1][j] |= dp[i][j] if j >= W[i]: dp[i+1][j] |= dp[i][j-W[i]] print('possible' if dp[N][target] else 'impossible')