結果

問題 No.4 おもりと天秤
ユーザー kaoru murata
提出日時 2021-08-26 12:18:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 332 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-18 08:53:44
合計ジャッジ時間 1,331 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_int(): return int(input())
def read_int_list(): return list(map(int, input().split()))


N = read_int()
Ws = read_int_list()
S = sum(Ws)
if S & 1 == 0:
    dp = 1
    for w in Ws:
        dp |= dp << w
    if dp >> (S // 2) & 1:
        print("possible")
    else:
        print("impossible")
else:
    print("impossible")
0