結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2022-11-02 14:28:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 379 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 69,408 KB |
最終ジャッジ日時 | 2024-07-17 03:55:25 |
合計ジャッジ時間 | 2,599 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 23 |
ソースコード
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]])