結果

問題 No.4 おもりと天秤
ユーザー szkhtsszkhts
提出日時 2022-02-06 09:19:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 8,188 KB
最終ジャッジ日時 2023-09-02 06:58:01
合計ジャッジ時間 4,672 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
8,000 KB
testcase_02 AC 51 ms
7,960 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 20 ms
8,044 KB
testcase_07 WA -
testcase_08 AC 252 ms
8,036 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 33 ms
8,100 KB
testcase_12 AC 23 ms
8,044 KB
testcase_13 AC 23 ms
7,964 KB
testcase_14 AC 24 ms
8,092 KB
testcase_15 AC 23 ms
7,964 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 252 ms
8,044 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

MAX = 10105
dp = [False] * MAX
N = int(input())
weights = list(map(int, input().split()))
sum = 0
for w in weights:
    sum += w

dp[0] = True
for i in range(N):
    for j in range(MAX - 1 - weights[i], -1, -1):
        dp[j + weights[i]] |= dp[j]

if (sum % 2 == 1) or (not dp[sum // 2]):
    print("impossible")
else:
    print("possiblle")
0