結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-07-18 11:40:36 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 64 ms / 5,000 ms | 
| コード長 | 503 bytes | 
| コンパイル時間 | 240 ms | 
| コンパイル使用メモリ | 82,848 KB | 
| 実行使用メモリ | 68,664 KB | 
| 最終ジャッジ日時 | 2024-07-18 11:40:38 | 
| 合計ジャッジ時間 | 1,802 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
N=int(input())
W=list(map(int,input().split()))
def prtb(mat):#二次元matを整えて表示する
    print("------")
    for m in mat:
    	print(*m)
    print("------")
if sum(W)%2==1:
	print("impossible")
	exit()
M=sum(W)//2
dp=[[0 for j in range(M+1)] for i in range(N+1)]
dp[0][0]=1
for i in range(N):
	for j in range(M+1):
		if j+W[i]<=M:
			dp[i+1][j+W[i]]=max(dp[i+1][j+W[i]],dp[i][j])
		dp[i+1][j]=max(dp[i+1][j],dp[i][j])
#prtb(dp)
print("possible" if dp[-1][-1]==1 else "impossible")
            
            
            
        