結果
問題 |
No.1135 RPN
|
ユーザー |
![]() |
提出日時 | 2020-07-28 04:39:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 546 bytes |
コンパイル時間 | 2,056 ms |
コンパイル使用メモリ | 197,880 KB |
最終ジャッジ日時 | 2025-01-12 07:05:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; stack<int> s; int a,b; string x; rep(i,n){ cin>>x; if(x=="+"){ a=s.top(); s.pop(); b=s.top(); s.pop(); s.push(b+a); } else if(x=="-"){ a=s.top(); s.pop(); b=s.top(); s.pop(); s.push(b-a); } else{ int y=stoi(x); s.push(y); } } cout<<s.top()<<endl; return 0; }