結果

問題 No.1135 RPN
ユーザー zeronosu77108
提出日時 2020-07-30 22:32:49
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 2,889 ms
コンパイル使用メモリ 138,876 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-04 22:08:09
合計ジャッジ時間 3,743 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <climits>
#include <map>
#include <queue>
#include <cmath>
#include <set>
#include <stdexcept>

using namespace std;

using int64 = long long;


int main() {
    int n;
    cin >> n;
    vector<int> st;
    for (int i=0; i<n; i++) {
        string c;
        cin >> c;
        if (c == "+" || c == "-") {
            int b = st.back(); st.pop_back();
            int a = st.back(); st.pop_back();
            int t = (c=="+"? a+b : a-b);
            st.push_back(t);
        } else {
            st.push_back(stoi(c));
        }
    }

    cout << st.back() << endl;
}
0