結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-27 02:21:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 5,000 ms |
| コード長 | 384 bytes |
| コンパイル時間 | 143 ms |
| コンパイル使用メモリ | 82,492 KB |
| 実行使用メモリ | 67,544 KB |
| 最終ジャッジ日時 | 2024-09-30 14:29:46 |
| 合計ジャッジ時間 | 1,681 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
n=int(input())
w=list(map(int,input().split()))
s=sum(w)
if s%2!=0:
print("impossible")
exit()
dp=[[0]*s for i in range(n+1)]
dp[0][0]=1
for i in range(n):
for j in range(s):
if dp[i][j]==1:
dp[i+1][j]=1
if j+w[i]<s:
dp[i+1][j+w[i]]=1
# print(dp)
if dp[n-1][int(s/2)]==1:
print("possible")
else:
print("impossible")