結果

問題 No.4 おもりと天秤
ユーザー HydruHydru
提出日時 2023-01-15 14:19:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 337 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 76,172 KB
最終ジャッジ日時 2023-08-27 21:53:20
合計ジャッジ時間 3,476 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,468 KB
testcase_01 AC 74 ms
71,356 KB
testcase_02 AC 73 ms
76,172 KB
testcase_03 AC 71 ms
71,440 KB
testcase_04 AC 71 ms
71,036 KB
testcase_05 AC 77 ms
76,160 KB
testcase_06 AC 69 ms
71,268 KB
testcase_07 AC 76 ms
75,928 KB
testcase_08 AC 72 ms
71,504 KB
testcase_09 AC 74 ms
75,936 KB
testcase_10 AC 78 ms
75,840 KB
testcase_11 AC 71 ms
71,144 KB
testcase_12 AC 71 ms
71,148 KB
testcase_13 AC 71 ms
71,316 KB
testcase_14 AC 70 ms
71,308 KB
testcase_15 AC 70 ms
71,308 KB
testcase_16 AC 69 ms
71,352 KB
testcase_17 AC 71 ms
71,508 KB
testcase_18 AC 82 ms
76,124 KB
testcase_19 AC 76 ms
75,928 KB
testcase_20 AC 77 ms
75,988 KB
testcase_21 AC 76 ms
76,084 KB
testcase_22 AC 77 ms
76,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
W=list(map(int,input().split()))

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

target=sum_W//2
box=set([0])
for w in W:
    n_box=set()
    for b in box:
        if b+w<=target:
            n_box.add(b+w)
    box|=n_box
    if target in box:
        print("possible")
        exit()

print("impossible")
0