結果
| 問題 | No.1135 RPN |
| ユーザー |
chacoder1
|
| 提出日時 | 2021-01-31 16:33:01 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 694 bytes |
| 記録 | |
| コンパイル時間 | 1,498 ms |
| コンパイル使用メモリ | 215,328 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-17 12:08:48 |
| 合計ジャッジ時間 | 2,579 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | WA * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(){
stack<int>sta;
int n;
cin>>n;
string s;
int a,b,x;
for(int i=0;i<n;i++){
x=0;
a=0;
b=0;
cin>>s;
if(s=="+"){
a=sta.top();
sta.pop();
b=sta.top();
sta.pop();
x=a+b;
sta.push(x);
continue;
}
if(s=="-"){
a=sta.top();
sta.pop();
b=sta.top();
sta.pop();
x=a-b;
sta.push(x);
continue;
}
for(int j=0;j<s.length();j++){
x+=s.at(j)-'0';
if(j != s.length()-1) x*=10;
}
sta.push(x);
}
x=sta.top();
cout<<x<<endl;
return 0;
}
chacoder1