結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2019-05-15 15:33:19 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 248 ms / 5,000 ms |
コード長 | 444 bytes |
コンパイル時間 | 491 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 14,848 KB |
最終ジャッジ日時 | 2024-09-14 01:55:37 |
合計ジャッジ時間 | 3,170 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
N = int(raw_input()) W = map(int, raw_input().split()) sum = 0 for i in range(0, N): sum += W[i] if sum % 2 == 1: print 'impossible' else: dp = [] for i in range(0, N+1): lst = [] for j in range(0, sum+1): lst.append(False) dp.append(lst) dp[0][0] = True for i in range(0, N): for j in range(0, sum+1): if dp[i][j]: dp[i+1][j] = True dp[i+1][j+W[i]] = True if dp[N][sum/2]: print 'possible' else: print 'impossible'