結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
CsTarepanda
|
| 提出日時 | 2017-05-04 00:12:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 426 bytes |
| コンパイル時間 | 102 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-09-14 07:11:20 |
| 合計ジャッジ時間 | 1,756 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 10 |
ソースコード
import sys
n = int(input())
a = list(map(int, input().split()))
ans = sum(a)
if ans & 1:
print("impossible")
sys.exit()
ans >>= 1
dp = {}
def solve(i, w):
if dp.get(w):
return None
dp[w] = True
if w < 0 or i >= n:
return None
if w == 0:
print("possible")
sys.exit()
return None
solve(i + 1, w - a[i])
solve(i + 1, w)
solve(0, ans)
print("impossible")
CsTarepanda