結果

問題 No.1135 RPN
ユーザー roaris
提出日時 2020-07-27 22:43:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 346 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 213 ms
コンパイル使用メモリ 85,412 KB
実行使用メモリ 55,200 KB
最終ジャッジ日時 2026-03-17 22:57:55
合計ジャッジ時間 1,308 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
from collections import *

N = int(input())
A = list(input().split())
q = deque([])

for Ai in A:
    if Ai=='+':
        a = q.pop()
        b = q.pop()
        q.append(a+b)
    elif Ai=='-':
        a = q.pop()
        b = q.pop()
        q.append(b-a)
    else:
        q.append(int(Ai))
    
print(q[0])
0