結果

問題 No.4 おもりと天秤
ユーザー vallyvally
提出日時 2023-08-28 12:43:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 76,176 KB
最終ジャッジ日時 2023-08-28 12:43:32
合計ジャッジ時間 3,973 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,248 KB
testcase_01 AC 75 ms
71,240 KB
testcase_02 AC 80 ms
75,788 KB
testcase_03 AC 77 ms
75,576 KB
testcase_04 AC 81 ms
75,992 KB
testcase_05 AC 84 ms
76,104 KB
testcase_06 AC 86 ms
71,324 KB
testcase_07 AC 82 ms
76,076 KB
testcase_08 AC 75 ms
71,356 KB
testcase_09 AC 78 ms
75,796 KB
testcase_10 AC 83 ms
75,948 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 75 ms
71,368 KB
testcase_14 WA -
testcase_15 AC 74 ms
71,464 KB
testcase_16 AC 77 ms
75,764 KB
testcase_17 AC 73 ms
71,572 KB
testcase_18 AC 83 ms
75,996 KB
testcase_19 AC 98 ms
76,176 KB
testcase_20 AC 83 ms
75,960 KB
testcase_21 AC 83 ms
76,036 KB
testcase_22 AC 80 ms
76,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = [int(i) for i in input().split()]
sum0 = sum(w)
if sum0 % 2 == 1:
    print('impossible')
else:
    half = sum0 // 2
    dp = [0 for i in range(sum0 // 2 + 1)]
    dp[0] = 1
    for i in w:
        for j in range(half + 1):
            if dp[j] == 1 and j + i <= half:
                dp[j + i] = 1
    if dp[half] ==1:
        print('possible')
    else:
        print('impossible')
0