結果

問題 No.4 おもりと天秤
ユーザー mationaruzoumationaruzou
提出日時 2020-06-19 13:19:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 395 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 15,828 KB
最終ジャッジ日時 2023-09-16 12:45:00
合計ジャッジ時間 3,457 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,088 KB
testcase_01 AC 15 ms
8,136 KB
testcase_02 AC 19 ms
8,228 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 15 ms
7,916 KB
testcase_07 WA -
testcase_08 AC 15 ms
8,232 KB
testcase_09 AC 397 ms
15,828 KB
testcase_10 WA -
testcase_11 AC 16 ms
7,764 KB
testcase_12 AC 16 ms
7,868 KB
testcase_13 AC 16 ms
7,928 KB
testcase_14 AC 16 ms
7,816 KB
testcase_15 AC 15 ms
7,852 KB
testcase_16 WA -
testcase_17 AC 15 ms
8,136 KB
testcase_18 AC 214 ms
12,100 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

W = list(map(int, input().split()))
W.sort()

s = sum(W)
if s % 2 == 1:
    print("impossible")
    exit()
dp = [[False]*(s+1) for _ in range(n)]
dp[0][W[0]] = True
for i in range(n-1):
    for j in range(s+1):
        if j >= W[i+1]:
            dp[i+1][j] = dp[i][j-W[i+1]]

for i in range(n):
    if dp[i][s//2]:
        print("possible")
        exit()
print("impossible")
0