結果

問題 No.1135 RPN
ユーザー roarisroaris
提出日時 2020-07-27 22:43:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 346 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 71,744 KB
最終ジャッジ日時 2023-09-11 06:05:07
合計ジャッジ時間 3,295 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
71,388 KB
testcase_01 AC 102 ms
71,500 KB
testcase_02 AC 102 ms
71,512 KB
testcase_03 AC 99 ms
71,700 KB
testcase_04 AC 103 ms
71,572 KB
testcase_05 AC 101 ms
71,380 KB
testcase_06 AC 102 ms
71,352 KB
testcase_07 AC 101 ms
71,716 KB
testcase_08 AC 101 ms
71,424 KB
testcase_09 AC 99 ms
71,500 KB
testcase_10 AC 100 ms
71,504 KB
testcase_11 AC 98 ms
71,692 KB
testcase_12 AC 102 ms
71,552 KB
testcase_13 AC 104 ms
71,560 KB
testcase_14 AC 102 ms
71,564 KB
testcase_15 AC 100 ms
71,744 KB
testcase_16 AC 102 ms
71,520 KB
testcase_17 AC 102 ms
71,496 KB
testcase_18 AC 102 ms
71,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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