結果
問題 |
No.2997 Making YuzuKizu
|
ユーザー |
![]() |
提出日時 | 2025-02-20 03:42:39 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 2,877 bytes |
コンパイル時間 | 13,405 ms |
コンパイル使用メモリ | 171,232 KB |
実行使用メモリ | 186,424 KB |
最終ジャッジ日時 | 2025-02-20 03:42:57 |
合計ジャッジ時間 | 16,025 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 17 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (113 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; public class Program { static void Main() { // 規定文字列 string Y = "yukari"; string A = "akari"; string X = "yuzukizu"; Dictionary<char, int> costDicY = new Dictionary<char, int>(); //yukari Dictionary<char, int> costDicA = new Dictionary<char, int>(); //akari Dictionary<char, int> costDicX = new Dictionary<char, int>(); //yuzukizu Dictionary<char, int> costDicS = new Dictionary<char, int>(); // 入力コスト // 最小出現回数 int minYlc; int minAlc; int minXlc; // 各文字毎にコストを定義 makeCostDictionary(ref costDicY, Y); makeCostDictionary(ref costDicA, A); makeCostDictionary(ref costDicX, X); // 入力文字列から各文字コストを算出 string S = Console.ReadLine(); makeCostDictionary(ref costDicS, S); // 最小回数初期化 minYlc = minAlc = minXlc = S.Length; // 文字出現回数をコストよりカウント int count; foreach(var pair in costDicY) { // 存在するなら計測 if(costDicS.ContainsKey(pair.Key)) { count = costDicS[pair.Key] / pair.Value; if(minYlc > count) minYlc = count; }else { // 不成立 minYlc = 0; break; } } // 文字出現回数をコストよりカウント foreach(var pair in costDicA) { // 存在するなら計測 if(costDicS.ContainsKey(pair.Key)) { count = costDicS[pair.Key] / pair.Value; if(minAlc > count) minAlc = count; }else { // 不成立 minAlc = 0; break; } } // 文字出現回数をコストよりカウント foreach(var pair in costDicX) { // 存在するなら計測 if(costDicS.ContainsKey(pair.Key)) { count = costDicS[pair.Key] / pair.Value; if(minXlc > count) minXlc = count; }else { // 不成立 minXlc = 0; break; } } Console.WriteLine($"{minYlc} {minAlc} {minXlc}"); } static void makeCostDictionary(ref Dictionary<char, int> dic, string costString) { foreach(char c in costString) { // 生成判定 if(!dic.ContainsKey(c))dic.Add(c, 0); //コスト増加 dic[c] += 1; } } }