結果

問題 No.4 おもりと天秤
ユーザー CsTarepandaCsTarepanda
提出日時 2017-05-04 00:09:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 388 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 12,632 KB
最終ジャッジ日時 2023-10-12 08:04:33
合計ジャッジ時間 7,335 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,204 KB
testcase_01 AC 15 ms
8,188 KB
testcase_02 AC 22 ms
7,844 KB
testcase_03 AC 16 ms
8,048 KB
testcase_04 AC 16 ms
8,084 KB
testcase_05 AC 15 ms
8,244 KB
testcase_06 AC 15 ms
7,840 KB
testcase_07 AC 15 ms
8,076 KB
testcase_08 AC 15 ms
8,132 KB
testcase_09 AC 15 ms
8,072 KB
testcase_10 AC 15 ms
8,044 KB
testcase_11 AC 15 ms
7,788 KB
testcase_12 AC 15 ms
7,848 KB
testcase_13 AC 15 ms
7,720 KB
testcase_14 AC 15 ms
7,832 KB
testcase_15 AC 15 ms
7,748 KB
testcase_16 AC 15 ms
8,104 KB
testcase_17 AC 15 ms
8,096 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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