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