結果

問題 No.4 おもりと天秤
ユーザー vallyvally
提出日時 2023-08-28 12:48:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 440 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2023-08-28 12:48:44
合計ジャッジ時間 3,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,304 KB
testcase_01 AC 73 ms
71,456 KB
testcase_02 AC 77 ms
75,644 KB
testcase_03 AC 82 ms
75,688 KB
testcase_04 AC 80 ms
75,692 KB
testcase_05 AC 85 ms
75,756 KB
testcase_06 AC 72 ms
71,436 KB
testcase_07 AC 83 ms
75,760 KB
testcase_08 AC 71 ms
71,384 KB
testcase_09 AC 78 ms
75,928 KB
testcase_10 AC 82 ms
75,912 KB
testcase_11 AC 76 ms
75,616 KB
testcase_12 AC 78 ms
71,328 KB
testcase_13 AC 73 ms
71,436 KB
testcase_14 AC 76 ms
70,896 KB
testcase_15 AC 75 ms
71,256 KB
testcase_16 AC 77 ms
75,508 KB
testcase_17 AC 71 ms
71,244 KB
testcase_18 AC 81 ms
76,160 KB
testcase_19 AC 84 ms
75,836 KB
testcase_20 AC 83 ms
76,060 KB
testcase_21 AC 84 ms
76,100 KB
testcase_22 AC 87 ms
75,980 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(half + 1)]
    dp[0] = 1
    for i in w:
        temp = dp.copy()
        for j in range(half + 1):
            

            if temp[j] == 1 and j + i <= half:
                dp[j + i] = 1
    if dp[half] ==1:
        print('possible')
    else:
        print('impossible')
0