結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
antyanpome
|
| 提出日時 | 2020-06-26 15:38:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 585 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 81,820 KB |
| 実行使用メモリ | 66,360 KB |
| 最終ジャッジ日時 | 2024-07-04 01:07:29 |
| 合計ジャッジ時間 | 2,135 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 4 |
ソースコード
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)]
dp[0][0] = True
for i in range(n):
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][-1] == True:
print("possible")
else:
print("impossible")
antyanpome