結果

問題 No.2927 Reverse Polish Equation
ユーザー 👑 p-adic
提出日時 2024-10-14 16:03:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 281 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 82,104 KB
実行使用メモリ 138,668 KB
最終ジャッジ日時 2024-10-16 00:32:35
合計ジャッジ時間 12,650 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 33 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

Y=int(input().split()[1])
S=input().split()
def f(x):
	A=[]
	for s in S:
		if"0">s:a=A.pop();A[-1]+=a
		elif"m">s:A+=[int(s)if"X">s else x]
		else:A[-2]=[min,max]["mi">s](A[-2:]);A.pop()
	return A[0]
l,r=0,Y+1
while l+1<r:
	m=(l+r)>>1
	if f(m)>Y:r=m
	else:l=m
print([l,-1][f(l)<Y])
0