結果

問題 No.4 おもりと天秤
ユーザー トミートミー
提出日時 2024-03-26 01:31:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 65,940 KB
最終ジャッジ日時 2024-03-26 01:31:22
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,332 KB
testcase_01 AC 38 ms
53,332 KB
testcase_02 AC 44 ms
59,508 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 34 ms
53,332 KB
testcase_09 AC 49 ms
65,840 KB
testcase_10 WA -
testcase_11 AC 40 ms
59,508 KB
testcase_12 RE -
testcase_13 AC 34 ms
53,332 KB
testcase_14 AC 34 ms
53,332 KB
testcase_15 AC 34 ms
53,332 KB
testcase_16 WA -
testcase_17 AC 34 ms
53,332 KB
testcase_18 AC 45 ms
63,788 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = list(map(int, input().split()))
if sum(w) % 2 == 1:
    print("impossible")
    exit()
else:
    div = int(sum(w)/2)
    # dp[i][j] i番目までのおもりをつかって重さjが作れるのか?
    dp = [[0 for j in range(div+1)] for i in range(n+1)]

    for i in range(n+1):
        dp[i][w[i-1]] = 1
        for j in range(div+1):
            if w[i-1] < j:
                dp[i][j] = max(dp[i-1][j-w[i-1]], 0)

    if dp[n][div]:
        print("possible")
    else:
        print("impossible")
0