結果

問題 No.4 おもりと天秤
コンテスト
ユーザー わん
提出日時 2025-10-20 04:25:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 69 ms / 5,000 ms
コード長 267 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 61,136 KB
最終ジャッジ日時 2025-10-20 04:25:44
合計ジャッジ時間 2,311 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

M = sum(A)
if M%2==1:
  print("impossible")
  exit()

L = M//2
dp = [0]*(L+1)
dp[0] = 1
for a in A:
  for i in range(L+1)[::-1]:
    if i-a >= 0:
      dp[i] |= dp[i-a]
print("possible" if dp[L] else "impossible")
0