結果
問題 | No.708 (+ー)の式 |
ユーザー |
![]() |
提出日時 | 2020-03-15 13:08:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 619 bytes |
コンパイル時間 | 2,033 ms |
コンパイル使用メモリ | 197,408 KB |
最終ジャッジ日時 | 2025-01-09 06:56:16 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include<bits/stdc++.h> #define endl enjoy_codeforces using lint=long long; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::string s;std::cin>>s; std::vector<lint>stack; stack.push_back(0); for(char c:std::string(s.rbegin(),s.rend())){ if('0'<=c&&c<='9'){ stack.push_back(c-'0'); }else if (c==')'){ stack.push_back(0); }else{ assert(2u<=stack.size()); lint x=stack.back();stack.pop_back(); stack.back()+=(c=='-'?-1:1)*x; } } std::cout<<stack.at(0)+stack.at(1)<<'\n'; }