結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
CsTarepanda
|
| 提出日時 | 2017-05-04 00:22:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 5,000 ms |
| コード長 | 452 bytes |
| コンパイル時間 | 82 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 13,824 KB |
| 最終ジャッジ日時 | 2024-06-26 10:15:22 |
| 合計ジャッジ時間 | 1,613 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import sys
n = int(input())
a = list(map(int, input().split()))
ans = sum(a)
if ans & 1:
print("impossible")
sys.exit()
ans >>= 1
dp = [{} for x in range(n)]
def solve(i, w):
if w < 0 or i >= n:
return None
if w == 0:
print("possible")
sys.exit()
return None
if dp[i].get(w):
return None
dp[i][w] = True
solve(i + 1, w - a[i])
solve(i + 1, w)
solve(0, ans)
print("impossible")
CsTarepanda