結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
antyanpome
|
| 提出日時 | 2020-06-26 15:32:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 564 bytes |
| コンパイル時間 | 138 ms |
| コンパイル使用メモリ | 82,288 KB |
| 実行使用メモリ | 74,424 KB |
| 最終ジャッジ日時 | 2024-07-04 00:59:43 |
| 合計ジャッジ時間 | 2,408 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 RE * 21 |
ソースコード
n = int(input())
w_list = list(map(int,input().split()))
all_weight = sum(w_list)
if all_weight%2==1:
print("impossible")
else:
target = all_weight//2
dp = [[False for i in range(target)] for i in range(n+1)]
for i in range(1,n+1):
for j in range(target):
if (j >= w_list[i] and dp[i][j - w_list[i]] == True) or dp[i][j] == True:
dp[i+1][j] = True
else:
dp[i+1][j] = False
if dp[-1][target] == True:
print("possible")
else:
print("impossible")
antyanpome