結果
問題 |
No.1135 RPN
|
ユーザー |
|
提出日時 | 2020-07-27 01:21:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 384 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 71,936 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 19:48:50 |
合計ジャッジ時間 | 1,397 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> #include<stack> using namespace std; int N; main() { cin>>N; stack<int>S; for(int i=0;i<N;i++) { string A;cin>>A; if(A=="+") { int a=S.top();S.pop(); int b=S.top();S.pop(); S.push(a+b); } else if(A=="-") { int a=S.top();S.pop(); int b=S.top();S.pop(); S.push(b-a); } else { S.push(stoi(A)); } } cout<<S.top()<<endl; }