結果

問題 No.4 おもりと天秤
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-02-09 01:32:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 585 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 78,268 KB
最終ジャッジ日時 2023-09-14 04:05:03
合計ジャッジ時間 7,490 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,644 KB
testcase_01 AC 64 ms
71,308 KB
testcase_02 AC 113 ms
77,656 KB
testcase_03 AC 87 ms
76,840 KB
testcase_04 AC 120 ms
78,268 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
N = int(input())
W = list(map(int, input().split()))

total_w = sum(W)
if total_w % 2 == 1:
    print("impossible")
    exit(0)


from copy import copy
def dfs(idx, lst):
    if sum(lst) == total_w // 2:
        return lst
    elif idx == N:
        return -1
    
    n_lst = copy(lst)
    res1 = dfs(idx+1, n_lst+[W[idx]])
    res2 = dfs(idx+1, n_lst)
    if res1 != -1 or res2 != -1:
        return 1
    else:
        return -1

if dfs(0, [])==1:
    print("possible")
else:
    print("impossible")

    

0