結果
| 問題 | No.1135 RPN |
| ユーザー |
|
| 提出日時 | 2020-07-30 22:32:49 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 674 bytes |
| 記録 | |
| コンパイル時間 | 2,708 ms |
| コンパイル使用メモリ | 147,456 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-03-26 04:39:28 |
| 合計ジャッジ時間 | 3,673 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#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;
}