using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { int[] inpt = Reader.ReadLine().Split().Select(a => int.Parse(a)).ToArray(); int openTime = inpt[0]; int maxCount = inpt[1]; long syojikin = inpt[2]; Kabuka = new int[openTime + 1]; State st = State.Even; for (int i = 0; i <= openTime; i++) { Kabuka[i] = int.Parse(Reader.ReadLine()); if(i>0) { if(Kabuka[i]>Kabuka[i-1]) { if (st == State.Even) { Tani.Add(0); } else if(st == State.Kudari) { Tani.Add(i - 1); } st = State.Nobori; } else if(Kabuka[i]=Kabuka.Length) { return money; } if(!Tani.Any(a=>a>=idx)) { return money; } int kai = Tani.First(a => a >= idx); if(!Yama.Any(a=>a>kai)) { return money; } int uri = Yama.First(a => a > kai); long kabu = money / Kabuka[kai]; long zan = money - (kabu * Kabuka[kai]); zan += Kabuka[uri] * kabu; ans = Math.Max(ans, GetAns(uri + 1, zan, remain - 1)); ans = Math.Max(ans, GetAns(kai + 1, money, remain)); return ans; } int[] Kabuka; private List Yama = new List(); private List Tani = new List(); private enum State { Nobori, Kudari, Even, } public class Reader { static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 21 5 3000 150 144 133 130 127 129 138 142 131 131 126 126 133 135 121 115 122 130 124 110 138 134 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }