package nowcoder.zte;
import java.util.Arrays;
public class Q3 {
public static void main(String[] args) {
int n = 4, P = 3, Q = 1;
int[] arr = {9, 8, 2, 5};
System.out.println(getMinCount(n, P, Q, arr));
}
private static int getMinCount(int n, int p, int q, int[] arr) {
int max = 0;
int res = 0;
boolean flag = true;
while (flag) {
max = getMax(arr);
arr[max] -= p;
for (int i = 0; i < n; i++) {
if (i == max)
continue;
arr[i] -= q;
}
// System.out.println(Arrays.toString(arr));
res++;
flag = false;
for (int i = 0; i < n; i++) {
if (arr[i] > 0)
flag = true;
}
}
return res;
}
private static int getMax(int[] arr) {
int max = 0;
int index = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
index = i;
}
}
return index;
}
}