結果
問題 |
No.714 回転寿司屋のシミュレート
|
ユーザー |
![]() |
提出日時 | 2019-02-06 16:40:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,744 bytes |
コンパイル時間 | 2,387 ms |
コンパイル使用メモリ | 115,296 KB |
実行使用メモリ | 31,948 KB |
最終ジャッジ日時 | 2024-06-11 21:53:45 |
合計ジャッジ時間 | 5,257 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 35 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; // No.714 回転寿司屋のシミュレート // https://yukicoder.me/problems/no/714 namespace no714 { class MainProgram { static void Main(string[] args) { Console.Write("order length: "); int len = -1; for (int i = 0; i < 10;) { if (int.TryParse(Console.ReadLine().Trim(), out len)) { break; } else { Console.WriteLine("-> E: not a number."); } } var customers = new List<Customer>(); for (int i = 0; i < len; i++) { Console.Write("order: "); var order = Console.ReadLine().Trim().Split(' '); int type = int.Parse(order[0]); switch (type) { case 0: // 入店処理 var tableNum = int.Parse(order[1]); var netas = new List<string>(); if(customers.Where(x => x.tableNumber == tableNum).Count() == 0) { if(tableNum < 21) { // テーブル番号20以下 Console.WriteLine("-> table ({0})", tableNum); Console.Write("-> neta > "); for (int j = 3; j < order.Length; j++) { netas.Add(order[j]); Console.Write("{0} ", order[j]); } customers.Add(new Customer(tableNum, netas)); Console.WriteLine(); } else { Console.WriteLine("E: table number have to 1 - 20."); } } else { Console.WriteLine("E: Already use table ({0}).", tableNum); } break; case 1: // ネタ流し customers = customers.OrderBy(x => x.tableNumber).ToList(); int c_index = -1; bool eatFlg = false; foreach (var c in customers) { c_index = c.netaList.IndexOf(order[1]); if(c_index < 0) { // 見つからなかった } else { Console.WriteLine("-> ({0}) table [{0}] eat {1}.", c.tableNumber, order[1]); c.netaList.Remove(order[1]); eatFlg = true; break; } } if(!eatFlg) { // 最後まで食べられなかった Console.WriteLine("-> (-1) No one eat {0}."); } break; case 2: // 退店処理 var cs = customers.Where(c => c.tableNumber == int.Parse(order[1])); if (cs.Count() > 0) { Console.WriteLine("-> table ({0}) leave.", cs.First().tableNumber); customers.Remove(cs.First()); } else { Console.WriteLine("E: table number ({0}) Empty.", order[1]); } break; case 9: Console.WriteLine("-----------------------"); foreach (var c in customers) { Console.WriteLine("table: {0}", c.tableNumber); Console.Write("neta : "); foreach(var neta in c.netaList) { Console.Write("{0} ", neta); } Console.WriteLine("\n-----------------------"); } break; default: break; } } Console.WriteLine("exit for press any key"); Console.ReadKey(); } } public class Customer { public int tableNumber { get; } public List<string> netaList { get; } public Customer(int num, List<string> neta) { tableNumber = num; netaList = neta; } } }