結果

問題 No.4 おもりと天秤
ユーザー wanwandarwanwandar
提出日時 2024-02-21 21:36:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 457 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 65,980 KB
最終ジャッジ日時 2024-02-21 21:36:20
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 43 ms
59,640 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 37 ms
53,460 KB
testcase_07 WA -
testcase_08 AC 37 ms
53,460 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 42 ms
59,644 KB
testcase_12 RE -
testcase_13 AC 38 ms
53,460 KB
testcase_14 AC 38 ms
53,460 KB
testcase_15 AC 36 ms
53,460 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 49 ms
61,832 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int, input().split()))
sum_W = sum(W)
ans = "impossible"
if sum_W % 2 == 1:
    pass
else:
    M = sum_W//2
    dp = [[False]*(M+1) for _ in range(N+1)]
    dp[0][0] = True
    for i in range(N):
        w = W[i]
        for j in range(M+1):
            if w < j:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = dp[i][j-w] or dp[i][j]
    if dp[-1][-1]:
        ans = "possible"
print(ans)
0