結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
mationaruzou
|
| 提出日時 | 2020-06-19 13:27:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 502 bytes |
| コンパイル時間 | 114 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 18,560 KB |
| 最終ジャッジ日時 | 2024-07-03 13:17:26 |
| 合計ジャッジ時間 | 2,788 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 WA * 1 |
ソースコード
n = int(input())
W = list(map(int, input().split()))
W.sort()
s = sum(W)
if s % 2 == 1:
print("impossible")
exit()
ss = s//2
dp = [[False]*(s+1) for _ in range(n)]
for i in range(n):
dp[i][0] = True
dp[0][W[0]] = True
for i in range(n-1):
for j in range(ss+1):
if j >= W[i+1]:
dp[i+1][j] = dp[i][j-W[i+1]]
if dp[i][j]:
dp[i+1][j] = True
for i in range(n):
if dp[i][ss]:
print("possible")
exit()
print("impossible")
mationaruzou