結果
問題 |
No.1135 RPN
|
ユーザー |
![]() |
提出日時 | 2020-09-08 14:17:17 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 1,059 ms |
コンパイル使用メモリ | 110,640 KB |
実行使用メモリ | 18,560 KB |
最終ジャッジ日時 | 2024-11-29 15:34:06 |
合計ジャッジ時間 | 2,321 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); getAns(n); } static void getAns(int n) { var st = new Stack<int>(); string[] line = Console.ReadLine().Trim().Split(' '); for (int i = 0; i < n; i++) { if (line[i] == "+") { var w = st.Pop() + st.Pop(); st.Push(w); } else if (line[i] == "-") { var w = -st.Pop() + st.Pop(); st.Push(w); } else st.Push(int.Parse(line[i])); } Console.WriteLine(st.Pop()); } }