結果
問題 | No.258 回転寿司(2) |
ユーザー | aketijyuuzou |
提出日時 | 2024-10-12 23:55:43 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 2,894 bytes |
コンパイル時間 | 1,247 ms |
コンパイル使用メモリ | 116,040 KB |
実行使用メモリ | 19,840 KB |
最終ジャッジ日時 | 2024-10-12 23:55:52 |
合計ジャッジ時間 | 7,862 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
19,840 KB |
testcase_01 | AC | 36 ms
19,584 KB |
testcase_02 | AC | 34 ms
19,328 KB |
testcase_03 | AC | 30 ms
19,328 KB |
testcase_04 | AC | 35 ms
19,712 KB |
testcase_05 | AC | 34 ms
19,712 KB |
testcase_06 | AC | 34 ms
19,584 KB |
testcase_07 | AC | 34 ms
19,584 KB |
testcase_08 | AC | 35 ms
19,328 KB |
testcase_09 | AC | 34 ms
19,584 KB |
testcase_10 | AC | 31 ms
19,200 KB |
testcase_11 | AC | 34 ms
19,584 KB |
testcase_12 | AC | 35 ms
19,584 KB |
testcase_13 | AC | 34 ms
19,456 KB |
testcase_14 | AC | 35 ms
19,712 KB |
testcase_15 | AC | 36 ms
19,712 KB |
testcase_16 | AC | 36 ms
19,712 KB |
testcase_17 | AC | 35 ms
19,712 KB |
testcase_18 | AC | 35 ms
19,584 KB |
testcase_19 | AC | 30 ms
19,200 KB |
testcase_20 | AC | 35 ms
19,584 KB |
testcase_21 | AC | 36 ms
19,584 KB |
testcase_22 | AC | 30 ms
19,072 KB |
testcase_23 | AC | 32 ms
19,200 KB |
testcase_24 | AC | 30 ms
19,200 KB |
testcase_25 | AC | 30 ms
19,328 KB |
testcase_26 | AC | 35 ms
19,712 KB |
testcase_27 | AC | 35 ms
19,456 KB |
testcase_28 | AC | 35 ms
19,456 KB |
testcase_29 | AC | 36 ms
19,456 KB |
testcase_30 | AC | 31 ms
19,328 KB |
testcase_31 | AC | 31 ms
19,072 KB |
testcase_32 | AC | 36 ms
19,456 KB |
testcase_33 | AC | 35 ms
19,456 KB |
testcase_34 | AC | 35 ms
19,584 KB |
testcase_35 | AC | 35 ms
19,328 KB |
testcase_36 | AC | 36 ms
19,712 KB |
testcase_37 | AC | 31 ms
19,328 KB |
testcase_38 | AC | 35 ms
19,456 KB |
testcase_39 | AC | 35 ms
19,328 KB |
testcase_40 | AC | 34 ms
19,456 KB |
testcase_41 | AC | 35 ms
19,584 KB |
testcase_42 | AC | 35 ms
19,584 KB |
testcase_43 | AC | 34 ms
19,712 KB |
testcase_44 | AC | 35 ms
19,456 KB |
testcase_45 | AC | 35 ms
19,456 KB |
testcase_46 | AC | 30 ms
19,328 KB |
testcase_47 | AC | 35 ms
19,584 KB |
testcase_48 | AC | 35 ms
19,456 KB |
testcase_49 | AC | 34 ms
19,456 KB |
testcase_50 | AC | 32 ms
19,328 KB |
testcase_51 | AC | 35 ms
19,328 KB |
testcase_52 | AC | 35 ms
19,584 KB |
testcase_53 | AC | 35 ms
19,712 KB |
testcase_54 | AC | 34 ms
19,584 KB |
testcase_55 | AC | 36 ms
19,584 KB |
testcase_56 | AC | 35 ms
19,456 KB |
testcase_57 | AC | 35 ms
19,584 KB |
testcase_58 | AC | 35 ms
19,584 KB |
testcase_59 | AC | 35 ms
19,712 KB |
testcase_60 | AC | 31 ms
19,200 KB |
testcase_61 | AC | 35 ms
19,200 KB |
testcase_62 | AC | 35 ms
19,584 KB |
testcase_63 | AC | 35 ms
19,712 KB |
testcase_64 | AC | 35 ms
19,840 KB |
testcase_65 | AC | 35 ms
19,456 KB |
testcase_66 | AC | 30 ms
19,328 KB |
testcase_67 | AC | 35 ms
19,712 KB |
testcase_68 | AC | 35 ms
19,584 KB |
testcase_69 | AC | 35 ms
19,712 KB |
testcase_70 | AC | 35 ms
19,584 KB |
コンパイルメッセージ
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("4"); WillReturn.Add("1 2 3 4"); //6 //2 4 } else if (InputPattern == "Input2") { WillReturn.Add("4"); WillReturn.Add("5 4 4 9"); //14 //1 4 } else if (InputPattern == "Input3") { WillReturn.Add("7"); WillReturn.Add("1 2 9 10 1 1 4"); //16 //2 4 7 } else if (InputPattern == "Input4") { WillReturn.Add("1"); WillReturn.Add("100"); //100 //1 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); int[] VArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray(); int UB = VArr.GetUpperBound(0); //最大の美味しさ合計[添字]なDP表 var DPArr = new Nullable<int>[UB + 1]; //配るDPでの配布元の添字 int[] MotoIndArr = new int[UB + 1]; for (int I = 0; I <= UB; I++) MotoIndArr[I] = -1; DPArr[0] = VArr[0]; if (UB > 0) DPArr[1] = VArr[1]; for (int I = 0; I <= UB; I++) { Action<int> UpdateAct = (pNewInd) => { if (pNewInd > UB) return; int NewVal = DPArr[I].Value + VArr[pNewInd]; if (DPArr[pNewInd].HasValue == false || DPArr[pNewInd].Value < NewVal) { DPArr[pNewInd] = NewVal; MotoIndArr[pNewInd] = I; } }; UpdateAct(I + 2); UpdateAct(I + 3); //for (int J = 0; J <= UB; J++) { // Console.WriteLine("DPArr[{0}]={1}", J, DPArr[J]); //} } //UBかUB-1が最大値 int MaxSumVal = DPArr[UB].Value; int CurrInd = UB; if (UB > 0 && DPArr[UB - 1].Value > MaxSumVal) { MaxSumVal = DPArr[UB - 1].Value; CurrInd = UB - 1; } Console.WriteLine(MaxSumVal); //DPの経路復元 var IndList = new List<int>(); while (CurrInd != -1) { IndList.Add(CurrInd); CurrInd = MotoIndArr[CurrInd]; } var sb = new System.Text.StringBuilder(); for (int I = IndList.Count - 1; 0 <= I; I--) { sb.Append(IndList[I] + 1); if (I > 0) sb.Append(' '); } Console.WriteLine(sb.ToString()); } }