結果

問題 No.4 おもりと天秤
コンテスト
ユーザー ytft
提出日時 2022-11-02 14:28:48
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 379 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 215 ms
コンパイル使用メモリ 85,760 KB
実行使用メモリ 69,248 KB
最終ジャッジ日時 2026-03-31 17:25:08
合計ジャッジ時間 2,019 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys,copy
input=lambda:sys.stdin.readline().rstrip()
N=int(input())
A=list(map(int,input().split()))
if sum(A)%2:
	print("Impossible")
	sys.exit()
targ=sum(A)//2
dp=[[0 for j in range(targ+1)] for i in range(N+1)]
dp[0][0]=1
for i in range(N):
	dp[i+1]=copy.copy(dp[i])
	for j in range(targ+1-A[i]):
		dp[i+1][j+A[i]]|=dp[i][j]
print(["Impossible","Possible"][dp[N][targ]])
0