結果

問題 No.1135 RPN
ユーザー phspls
提出日時 2020-08-01 15:46:11
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 11,567 ms
コンパイル使用メモリ 403,868 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-08 02:45:00
合計ジャッジ時間 12,698 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();

    let mut result: Vec<isize> = vec![];
    a.trim().split_whitespace().for_each(|s| {
        if s.parse::<isize>().is_ok() {
            result.push(s.parse().unwrap());
        } else {
            let a = result.pop().unwrap();
            let b = result.pop().unwrap();
            if s == "+" {
                result.push(a + b);
            } else {
                result.push(b - a);
            }
        }
    });
    println!("{}", result.pop().unwrap());
}
0