結果
問題 | No.1594 Three Classes |
ユーザー |
![]() |
提出日時 | 2025-02-20 21:59:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 944 ms / 2,000 ms |
コード長 | 2,384 bytes |
コンパイル時間 | 5,167 ms |
コンパイル使用メモリ | 112,480 KB |
実行使用メモリ | 32,204 KB |
最終ジャッジ日時 | 2025-02-20 21:59:21 |
合計ジャッジ時間 | 15,848 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
コンパイルメッセージ
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; // https://yukicoder.me/problems/no/1594 class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("5"); WillReturn.Add("1 2 3 4 5"); } else if (InputPattern == "Input2") { WillReturn.Add("7"); WillReturn.Add("3 1 4 1 5 9 2"); } else if (InputPattern == "Input3") { WillReturn.Add("9"); WillReturn.Add("729 756 767 778 792 804 816 831 855"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); long[] EArr = InputList[1].Split(' ').Select(pX => long.Parse(pX)).ToArray(); long UB = EArr.GetUpperBound(0); var Stk = new Stack<JyoutaiDef>(); JyoutaiDef WillPush; WillPush.ValList = new List<long>(); WillPush.CurrInd = 0; Stk.Push(WillPush); while (Stk.Count > 0) { JyoutaiDef Popped = Stk.Pop(); int CurrInd = Popped.CurrInd; if (CurrInd > UB) { if (Popped.ValList.Count == 3) { if (Popped.ValList.Distinct().Count() == 1) { Console.WriteLine("Yes"); return; } } continue; } // Listの要素に足し算する場合 for (int I = 0; I <= Popped.ValList.Count - 1; I++) { WillPush.ValList = new List<long>(Popped.ValList); WillPush.ValList[I] = Popped.ValList[I] + EArr[CurrInd]; WillPush.CurrInd = CurrInd + 1; Stk.Push(WillPush); } // ListにAddする場合 WillPush.ValList = new List<long>(Popped.ValList); WillPush.ValList.Add(EArr[CurrInd]); WillPush.CurrInd = CurrInd + 1; Stk.Push(WillPush); } Console.WriteLine("No"); } struct JyoutaiDef { internal List<long> ValList; internal int CurrInd; } }