結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-09 20:43:51 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 640 bytes |
| コンパイル時間 | 599 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 136,692 KB |
| 最終ジャッジ日時 | 2024-06-23 16:35:51 |
| 合計ジャッジ時間 | 7,819 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 1 -- * 4 |
ソースコード
#!/usr/bin/env python3
def memoize(f):
table = {}
def func(*args):
if args not in table:
table[args] = f(*args)
return table[args]
return func
@memoize
def ok(weight, rest):
if weight < 0:
return False
if weight == 0:
return True
for w in rest:
r = list(rest)
r.remove(w)
if ok(weight - w, tuple(sorted(r))):
return True
return False
N = int(input())
W = [int(x) for x in input().split()]
if sum(W) % 2 == 1:
print("impossible")
exit()
if ok(sum(W) // 2, tuple(W)):
print("possible")
else:
print("impossible")