結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2019-05-03 19:46:44 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,419 ms / 5,000 ms |
コード長 | 516 bytes |
コンパイル時間 | 369 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-12-31 16:09:16 |
合計ジャッジ時間 | 9,055 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
N = int(input()) W = list(map(int,input().split())) c_idx = sum(W) dp = [False] * (2 * c_idx) dp[c_idx + W[0]] = True dp[c_idx - W[0]] = True dp2 = [False] * len(dp) for i in range(N -1): for x in range(2* c_idx): if x < W[i+1]: dp2[x] = dp[x + W[i+1]] elif x + W[i+1] > len(dp) -1: dp2[x] = dp[x - W[i+1]] else: dp2[x] = dp[x + W[i+1]] or dp[x - W[i+1]] dp, dp2 = dp2, dp if dp[c_idx] == True: print('possible') else: print('impossible')