結果

問題 No.4 おもりと天秤
ユーザー トミートミー
提出日時 2024-03-27 02:21:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 384 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 67,728 KB
最終ジャッジ日時 2024-03-27 02:21:55
合計ジャッジ時間 2,212 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,332 KB
testcase_01 AC 34 ms
53,332 KB
testcase_02 AC 38 ms
59,528 KB
testcase_03 AC 38 ms
59,528 KB
testcase_04 AC 38 ms
59,528 KB
testcase_05 AC 46 ms
63,736 KB
testcase_06 AC 34 ms
53,332 KB
testcase_07 AC 48 ms
63,732 KB
testcase_08 AC 35 ms
53,332 KB
testcase_09 AC 49 ms
67,728 KB
testcase_10 AC 47 ms
63,556 KB
testcase_11 AC 37 ms
59,400 KB
testcase_12 AC 33 ms
53,332 KB
testcase_13 AC 33 ms
53,332 KB
testcase_14 AC 36 ms
57,300 KB
testcase_15 AC 39 ms
53,332 KB
testcase_16 AC 38 ms
59,400 KB
testcase_17 AC 34 ms
53,332 KB
testcase_18 AC 45 ms
63,624 KB
testcase_19 AC 46 ms
63,628 KB
testcase_20 AC 46 ms
63,756 KB
testcase_21 AC 45 ms
63,764 KB
testcase_22 AC 50 ms
63,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
w=list(map(int,input().split()))
s=sum(w)
if s%2!=0:
    print("impossible")
    exit()
dp=[[0]*s for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(s):
        if dp[i][j]==1:
            dp[i+1][j]=1
            if j+w[i]<s:
                dp[i+1][j+w[i]]=1

# print(dp)
if dp[n-1][int(s/2)]==1:
    print("possible")
else:
    print("impossible")
0