結果

問題 No.4 おもりと天秤
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-02-09 15:34:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 553 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 14,904 KB
最終ジャッジ日時 2023-09-14 11:45:27
合計ジャッジ時間 7,579 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,840 KB
testcase_01 AC 15 ms
8,280 KB
testcase_02 AC 101 ms
14,904 KB
testcase_03 AC 21 ms
8,740 KB
testcase_04 AC 24 ms
8,944 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 collections import deque
from copy import copy
dq = deque([ (0, [])] ) 
while dq:
    idx, lst = dq.popleft()
    if sum(lst) == total_w//2:
            print("possible")
            exit(0)
    elif idx == N:
        continue
    n_lst = copy(lst)
    dq.append( (idx+1, n_lst) )
    dq.append( (idx+1, n_lst+[W[idx]]) )
print("impossible")


0