結果
問題 |
No.2559 眩しい数直線
|
ユーザー |
![]() |
提出日時 | 2025-02-18 14:59:51 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 2,666 bytes |
コンパイル時間 | 4,415 ms |
コンパイル使用メモリ | 119,692 KB |
実行使用メモリ | 28,108 KB |
最終ジャッジ日時 | 2025-02-18 14:59:58 |
合計ジャッジ時間 | 5,281 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
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; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("2 5"); WillReturn.Add("1 2"); WillReturn.Add("4 3"); } else if (InputPattern == "Input2") { WillReturn.Add("5 6"); WillReturn.Add("5 3"); WillReturn.Add("2 1"); WillReturn.Add("3 4"); WillReturn.Add("5 3"); WillReturn.Add("3 6"); } else if (InputPattern == "Input3") { WillReturn.Add("10 20"); WillReturn.Add("1 1"); WillReturn.Add("5 18"); WillReturn.Add("3 12"); WillReturn.Add("8 5"); WillReturn.Add("6 10"); WillReturn.Add("8 7"); WillReturn.Add("19 6"); WillReturn.Add("20 11"); WillReturn.Add("6 16"); WillReturn.Add("19 16"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); int[] wkArr = { }; Action<string> SplitAct = pStr => wkArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray(); SplitAct(InputList[0]); int X = wkArr[1]; var ValDict = new Dictionary<int, int>(); for (int I = 1; I <= X; I++) { ValDict[I] = 0; } foreach (string EachStr in InputList.Skip(1)) { SplitAct(EachStr); int A = wkArr[0]; int B = wkArr[1]; int CurrVal = B; for (int I = 0; I <= B; I++) { int Pos1 = A + I; int Pos2 = A - I; if (1 <= Pos1 && Pos1 <= X) { ValDict[Pos1] = Math.Max(ValDict[Pos1], CurrVal); } if (1 <= Pos2 && Pos2 <= X) { ValDict[Pos2] = Math.Max(ValDict[Pos2], CurrVal); } if (--CurrVal == 0) break; } } Console.WriteLine(IntEnumJoin(" ", ValDict.Values)); } // セパレータとInt型の列挙を引数として、結合したstringを返す static string IntEnumJoin(string pSeparater, IEnumerable<int> pEnum) { string[] StrArr = Array.ConvertAll(pEnum.ToArray(), pX => pX.ToString()); return string.Join(pSeparater, StrArr); } }