結果

問題 No.4 おもりと天秤
ユーザー myukii
提出日時 2016-09-16 11:15:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 435 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-26 10:01:31
合計ジャッジ時間 2,744 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ws = list(input().split())

sum_w = 0

for w in ws:
    sum_w += int(w)


mode_sum_w = sum_w % 2

if mode_sum_w != 0 :
    print('impossible\n')
    exit()

checks = [False] * (sum_w + 1)
checks[0] = True
for w in ws :
    for i in range(sum_w, -1, -1) :
        if not checks[i] :
            continue

        checks[i + int(w)] = True

if checks[sum_w // 2]:
    print("possible\n")
else:
    print("impossible\n")
0