結果

問題 No.4 おもりと天秤
ユーザー vally
提出日時 2023-08-28 12:48:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 440 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 82,012 KB
実行使用メモリ 63,924 KB
最終ジャッジ日時 2024-12-29 12:06:44
合計ジャッジ時間 2,154 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = [int(i) for i in input().split()]
sum0 = sum(w)
if sum0 % 2 == 1:
    print('impossible')
else:
    half = sum0 // 2
    dp = [0 for i in range(half + 1)]
    dp[0] = 1
    for i in w:
        temp = dp.copy()
        for j in range(half + 1):
            

            if temp[j] == 1 and j + i <= half:
                dp[j + i] = 1
    if dp[half] ==1:
        print('possible')
    else:
        print('impossible')
0