結果
| 問題 |
No.1135 RPN
|
| ユーザー |
forest3
|
| 提出日時 | 2020-07-30 12:28:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 468 bytes |
| コンパイル時間 | 1,692 ms |
| コンパイル使用メモリ | 171,664 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-03 21:43:56 |
| 合計ジャッジ時間 | 2,195 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
stack<long long> st;
for( int i = 0; i < N; i++ ) {
string A;
cin >> A;
if( A[0] != '+' && A[0] != '-' ) {
long long a = atoll( A.c_str() );
st.push( a );
}
else {
long long y = st.top();
st.pop();
long long x = st.top();
st.pop();
if( A[0] == '+' ) st.push( x + y );
else st.push( x - y );
}
}
long long ans = st.top();
cout << ans << endl;
}
forest3