結果

問題 No.4 おもりと天秤
ユーザー Luoto-green
提出日時 2017-07-31 19:42:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 480 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-11 00:10:45
合計ジャッジ時間 1,531 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = [int(i)for i in input().split()]
def solve(n,A):
    s = sum(A)
    B = set([0])
    h = s//2
    if s&1:
        return False
    else:
        for i in A:
            nB = set(B)
            for j in B:
                ij = i + j
                if ij == h//2:
                    return True
                if ij < h:
                    nB.add(ij)
            B = nB
        return False
if solve(n,A):
    print("possible")
else:
    print("impossible")
0