結果

問題 No.4 おもりと天秤
ユーザー otsuneko
提出日時 2021-04-25 01:44:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 97,280 KB
最終ジャッジ日時 2024-07-04 09:22:22
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
def dfs(idx,w):
    if (idx,w) in seen:
        return
    for i in range(idx,N):
        if w + W[i] == total_w/2:
            print("possible")
            exit()
        elif w + W[i] < total_w/2:
            seen.add((i,w))
            dfs(i+1,w+W[i])
            dfs(i+1,w)
        else:
            return

N = int(input())
W = list(map(int,input().split()))
total_w = sum(W)

if total_w/2 != total_w//2:
    print("impossible")
    exit()

idx = 0
w = 0
seen = set([])
dfs(idx,w)
print("impossible")
0