結果

問題 No.4 おもりと天秤
ユーザー DrDrpilotDrDrpilot
提出日時 2022-06-21 16:21:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 566 ms / 5,000 ms
コード長 351 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 18,304 KB
最終ジャッジ日時 2024-04-22 10:47:54
合計ジャッジ時間 4,865 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 34 ms
10,752 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 37 ms
10,880 KB
testcase_05 AC 349 ms
14,848 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 334 ms
14,848 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 AC 566 ms
18,304 KB
testcase_10 AC 355 ms
15,360 KB
testcase_11 AC 28 ms
10,752 KB
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 27 ms
10,624 KB
testcase_14 AC 28 ms
10,624 KB
testcase_15 AC 28 ms
10,752 KB
testcase_16 AC 29 ms
10,752 KB
testcase_17 AC 26 ms
10,624 KB
testcase_18 AC 308 ms
14,464 KB
testcase_19 AC 287 ms
14,336 KB
testcase_20 AC 320 ms
14,208 KB
testcase_21 AC 267 ms
14,336 KB
testcase_22 AC 273 ms
14,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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