using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { int monsterCount = int.Parse(Reader.ReadLine()); int[] mikataArr = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int[] tekiArr = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int max = int.MaxValue; for (int i = 0; i < monsterCount; i++) { SortedDictionary mikata = new SortedDictionary(); mikataArr.ToList().ForEach(a=>mikata.Add(new Monster(mikata.Count, a), true)); List tekiList = new List(tekiArr.Skip(i)); tekiList.AddRange(tekiArr.Take(i)); int subMax = 0; bool mustBreak = false; for (int j = 0; j < monsterCount; j++) { Monster m = mikata.First().Key; mikata.Remove(m); m.Level += tekiList[i] / 2; m.BattleCount++; subMax = Math.Max(subMax, m.BattleCount); mikata.Add(m, true); if(subMax >= max) { mustBreak = true; break; } } if(mustBreak) { continue; } max = Math.Min(max, subMax); } Console.WriteLine(max); } private class Monster : IComparable, IEquatable { public int Level; public int BattleCount; public int ID; public int CompareTo(object obj) { Monster mns = (Monster)obj; if (this.Level == mns.Level) { if(this.BattleCount == mns.BattleCount) { return this.ID.CompareTo(mns.ID); } return this.BattleCount.CompareTo(mns.BattleCount); } return this.Level.CompareTo(mns.Level); } public Monster(int id, int level) { this.Level = level; this.BattleCount = 0; this.ID = id; } public bool Equals(Monster obj) { return obj.ID == this.ID; } } public class Reader { private 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 = @" 5 6 1 5 9 2 7 7 9 4 4 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }