import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; public class Program { public static void main(String[] args) { new Magatro().solve(); } } class Magatro { private int n; private int[] a, b; private PriorityQueue priorityQueue; private int anser = Integer.MAX_VALUE; private void scan() { Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); a = new int[n]; b = new int[n]; for (int i = 0; i < n; i++) { a[i] = scanner.nextInt(); } for (int i = 0; i < n; i++) { b[i] = scanner.nextInt(); } } private void battle(int start) { int result = -1; PriorityQueue copyPq = new PriorityQueue(priorityQueue); for (int i = 0; i < n; i++) { int index = (i+start)%n; Mon mon = copyPq.poll(); mon.battle++; result = Math.max(mon.battle, result); if(anser<=result)return; mon.level += b[index]/2; copyPq.add(mon); } anser = result; } public void solve() { scan(); priorityQueue = new PriorityQueue<>(1, new MyComparator()); for (int i : a) { priorityQueue.add(new Mon(i)); } for(int i=0;i { public int compare(Mon a, Mon b) { if (a.level != b.level) { return Integer.compare(a.level, b.level); } else { return Integer.compare(a.battle, b.battle); } } } class Mon { public int level; public int battle; public Mon(int l) { level = l; battle = 0; } }