結果
問題 | No.2927 Reverse Polish Equation |
ユーザー |
|
提出日時 | 2024-09-07 11:56:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 709 ms / 2,000 ms |
コード長 | 500 bytes |
コンパイル時間 | 375 ms |
コンパイル使用メモリ | 82,284 KB |
実行使用メモリ | 201,232 KB |
最終ジャッジ日時 | 2024-10-16 00:21:05 |
合計ジャッジ時間 | 13,379 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
q,y=map(int,input().split())s=input().split()def f(x:int):d=[]for i in s:if i=="X":d.append(x)elif i=="min":d.append(min(d.pop(),d.pop()))elif i=="max":d.append(max(d.pop(),d.pop()))elif i=="+":d.append(d.pop()+d.pop())else:d.append(int(i))return d[0]l=-1r=10**18while r-l>1:m=(l+r)//2if f(m)<y:l=melse:r=mif f(r)==y:print(r)else:print(-1)