結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
asumo0729
|
| 提出日時 | 2020-12-16 17:03:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 5,000 ms |
| コード長 | 590 bytes |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 60,800 KB |
| 最終ジャッジ日時 | 2024-09-20 05:10:45 |
| 合計ジャッジ時間 | 2,049 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
import sys
stdin=sys.stdin
ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
tp=lambda:tuple(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
yp=lambda:print('Yes')
np=lambda:print('No')
n=ip()
w=lp()
s=sum(w)
if s%2==1:
print('impossible')
else:
half=s//2
dp=[-1 for _ in range(half+1)]
dp[0]=0
for now in w:
for i in range(half,-1,-1):
if i-now>=0 and dp[i-now]!=-1:
dp[i]=0
if dp[half]==-1:
print('impossible')
else:
print('possible')
asumo0729