結果

問題 No.1135 RPN
ユーザー ssmkzk
提出日時 2020-10-29 02:38:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-21 22:29:34
合計ジャッジ時間 1,266 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
l = list(map(str, input().split()))

st = []

for li in l:
    if li == "+":
        add = st[-1] + st[-2]
        st.pop()
        st.pop()
        st.append(add)
    elif li == "-":
        add = st[-2] - st[-1] 
        st.pop()
        st.pop()
        st.append(add)    
    else:
        st.append(int(li))

print(st[0])
0