using System; using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Text; using System.Net; public class Program { public void Proc() { int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); int dayCount = inpt[0]; int amount = inpt[2]; this.range = inpt[1]; SortedDictionary> dic = new SortedDictionary>(); for(int i=0; i()); } dic[tmp].Add(i); } int ans = GetAns(0, dic.Last().Key, dic); Console.WriteLine(ans * amount); if(ans > 0) { Console.WriteLine(fromIdx + " " + toIdx); } } private int GetAns(int min, int max, SortedDictionary> dic) { if(max-min<=1) { if(CanSet(max, dic)) { return max; } else { return min; } } int mid = (max+min)/2; if(CanSet(mid, dic)) { return GetAns(mid, max, dic); } else { return GetAns(min, mid, dic); } } private int range = 0; private int fromIdx = -1; private int toIdx = -1; private bool CanSet(int target , SortedDictionary> dic) { if(target <= 0) { return true; } int[] keys = dic.Keys.ToArray(); for(int i=0; ikeys[j]) { continue; } if(dic[keys[i]].First() > dic[keys[j]].Last()) { continue; } int subIdx = 0; for(int k=0; k dic[keys[i]][k] + range) { break; } this.fromIdx = dic[keys[i]][k]; this.toIdx = dic[keys[j]][l]; return true; } } } } return false; } public class Reader { public static bool IsDebug = false; private static System.IO.StringReader SReader; private static string InitText = @" 7 2 1000 1 3 5 1 4 4 7 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }