結果

問題 No.4 おもりと天秤
ユーザー momoyuumomoyuu
提出日時 2022-08-03 00:00:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 454 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 86,668 KB
実行使用メモリ 75,828 KB
最終ジャッジ日時 2023-10-01 00:38:09
合計ジャッジ時間 3,330 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,032 KB
testcase_01 AC 71 ms
70,968 KB
testcase_02 AC 82 ms
75,616 KB
testcase_03 AC 76 ms
75,828 KB
testcase_04 AC 77 ms
75,624 KB
testcase_05 AC 87 ms
75,708 KB
testcase_06 AC 71 ms
71,060 KB
testcase_07 AC 85 ms
75,636 KB
testcase_08 AC 78 ms
74,716 KB
testcase_09 AC 86 ms
75,636 KB
testcase_10 AC 84 ms
75,512 KB
testcase_11 AC 75 ms
75,424 KB
testcase_12 AC 71 ms
70,956 KB
testcase_13 AC 74 ms
71,088 KB
testcase_14 AC 74 ms
74,852 KB
testcase_15 AC 70 ms
71,144 KB
testcase_16 AC 76 ms
75,224 KB
testcase_17 AC 72 ms
71,160 KB
testcase_18 AC 82 ms
75,620 KB
testcase_19 AC 85 ms
75,424 KB
testcase_20 AC 84 ms
75,764 KB
testcase_21 AC 85 ms
75,528 KB
testcase_22 AC 87 ms
75,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int,input().split()))
sum = 0
for i in range(N):
    sum += W[i]
dp = [[0 for _ in range(sum+1)] for _ in range(N)]
dp[0][0] = 1
if sum % 2 == 1:
    print("impossible")
    exit()

dp[0][W[0]] = 1

for i in range(1,N):
    for j in range(sum+1):
        if dp[i-1][j] == 0:
            continue
        dp[i][j] = 1
        dp[i][j+W[i]] = 1

if dp[N-1][sum//2] == 1:
    print("possible")
else:
    print("impossible")



0