結果

問題 No.4 おもりと天秤
ユーザー AEnAEn
提出日時 2022-05-16 16:05:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 389 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 85,000 KB
最終ジャッジ日時 2023-10-12 09:14:45
合計ジャッジ時間 3,536 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,352 KB
testcase_01 AC 72 ms
71,660 KB
testcase_02 AC 81 ms
76,248 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 71 ms
71,516 KB
testcase_07 WA -
testcase_08 AC 75 ms
71,192 KB
testcase_09 AC 113 ms
85,000 KB
testcase_10 WA -
testcase_11 AC 78 ms
76,156 KB
testcase_12 AC 76 ms
71,448 KB
testcase_13 AC 75 ms
71,524 KB
testcase_14 AC 78 ms
71,292 KB
testcase_15 AC 76 ms
71,372 KB
testcase_16 WA -
testcase_17 AC 76 ms
71,340 KB
testcase_18 AC 94 ms
76,236 KB
testcase_19 AC 92 ms
76,284 KB
testcase_20 AC 92 ms
76,064 KB
testcase_21 AC 93 ms
76,048 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

sm = sum(W)
if sm%2 == 1:
    print('impossible')
    exit()
dp = [[True]+[False]*sm for _ in range(N)]
dp[0][W[0]] = True
for i in range(1, N):
    for j in range(sm+1):
        dp[i][j] = dp[i-1][j]
        if j - W[i] >= 0:
            dp[i][j] = dp[i-1][j-W[i]]
if dp[-1][sm//2]:
    print('possible')
else:
    print('impossible')
0