結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-07-29 20:38:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 127 ms / 5,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2024-06-26 09:37:21 |
合計ジャッジ時間 | 2,022 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
def rec(i, j): #if dp[i][j] != -1: # return dp[i][j] if i in dphash and j in dphash[i]: return dphash[i][j] if i == N: if j == 0: ret = True else: ret = False else: ret = rec(i + 1, j + W[i]) or rec(i + 1, j - W[i]) if i in dphash: dphash[i][j] = ret else: dphash[i] = {} dphash[i][j] = ret return ret N = int(input()) W = list(map(int, input().split())) #dp = [[-1 for j in range(10001)] for i in range(101)] dphash = {} if rec(0, 0): print("possible") else: print("impossible")