結果

問題 No.4 おもりと天秤
ユーザー brthyyjpbrthyyjp
提出日時 2021-11-02 00:55:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 62,336 KB
最終ジャッジ日時 2024-04-19 02:47:47
合計ジャッジ時間 2,352 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,352 KB
testcase_01 AC 36 ms
51,968 KB
testcase_02 AC 42 ms
58,240 KB
testcase_03 AC 40 ms
58,496 KB
testcase_04 AC 47 ms
58,880 KB
testcase_05 AC 50 ms
61,880 KB
testcase_06 AC 36 ms
51,712 KB
testcase_07 AC 49 ms
62,336 KB
testcase_08 AC 36 ms
51,712 KB
testcase_09 AC 49 ms
62,336 KB
testcase_10 AC 52 ms
61,868 KB
testcase_11 AC 40 ms
57,344 KB
testcase_12 AC 37 ms
51,584 KB
testcase_13 AC 37 ms
51,712 KB
testcase_14 AC 36 ms
51,968 KB
testcase_15 AC 36 ms
51,968 KB
testcase_16 AC 39 ms
57,984 KB
testcase_17 AC 37 ms
51,968 KB
testcase_18 AC 46 ms
60,928 KB
testcase_19 AC 48 ms
61,568 KB
testcase_20 AC 48 ms
61,952 KB
testcase_21 AC 47 ms
61,568 KB
testcase_22 AC 47 ms
61,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
W = list(map(int, input().split()))
s = sum(W)
if s%2 != 0:
    print('impossible')
    exit()
dp = [False]*(s//2+1)
dp[0] = True
for w in W:
    nx = [False]*(s//2+1)
    for j in range(s//2+1):
        if dp[j]:
            nx[j] = True
            if j+w <= s//2:
                nx[j+w] = True
    dp = nx
if dp[s//2]:
    print('possible')
else:
    print('impossible')
0