結果
| 問題 |
No.1135 RPN
|
| ユーザー |
|
| 提出日時 | 2020-07-26 22:45:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 417 bytes |
| コンパイル時間 | 2,833 ms |
| コンパイル使用メモリ | 196,864 KB |
| 最終ジャッジ日時 | 2025-01-12 06:28:00 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
int n; cin>>n;
stack<int> S;
rep(_,n){
string s; cin>>s;
if(s=="+"){
int a=S.top(); S.pop();
int b=S.top(); S.pop();
S.push(b+a);
}
else if(s=="-"){
int a=S.top(); S.pop();
int b=S.top(); S.pop();
S.push(b-a);
}
else{
S.push(stoi(s));
}
}
printf("%d\n",S.top());
return 0;
}