結果

問題 No.4 おもりと天秤
ユーザー satama123satama123
提出日時 2023-11-11 23:28:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 63,916 KB
最終ジャッジ日時 2023-11-11 23:28:26
合計ジャッジ時間 2,161 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 38 ms
59,652 KB
testcase_03 WA -
testcase_04 AC 39 ms
59,648 KB
testcase_05 AC 45 ms
61,812 KB
testcase_06 AC 34 ms
53,460 KB
testcase_07 AC 45 ms
63,916 KB
testcase_08 AC 33 ms
53,460 KB
testcase_09 AC 46 ms
63,748 KB
testcase_10 AC 45 ms
61,684 KB
testcase_11 AC 37 ms
59,524 KB
testcase_12 AC 34 ms
53,460 KB
testcase_13 AC 34 ms
53,460 KB
testcase_14 AC 35 ms
53,460 KB
testcase_15 AC 34 ms
53,460 KB
testcase_16 WA -
testcase_17 AC 35 ms
53,460 KB
testcase_18 AC 45 ms
61,688 KB
testcase_19 AC 45 ms
61,700 KB
testcase_20 AC 46 ms
61,828 KB
testcase_21 AC 46 ms
61,828 KB
testcase_22 AC 45 ms
61,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int, input().split()))
S = sum(W)

if S & 1 : exit(print("impossible"))
S //= 2
dp = [[False for _ in range(S + 1)] for _ in range(N + 1)]
dp[0][0] = True

for i in range(N):
    w = W[i]

    for s in range(S):
        if not dp[i][s] : continue
        if w + s > S : break
        dp[i + 1][s + w] = True
        dp[i + 1][s] = True

if dp[N][S] : print("possible")
else : print("impossible")
0