結果

問題 No.4 おもりと天秤
コンテスト
ユーザー CsTarepanda
提出日時 2017-05-04 00:09:58
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 388 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 370 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 23,328 KB
最終ジャッジ日時 2026-04-04 11:07:18
合計ジャッジ時間 9,012 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 w
    solve(i + 1, w - a[i])
    solve(i + 1, w)

solve(0, ans)
print("impossible")
0