Problem:
Score : 400 points

Problem Statement

You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.

Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:

Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.

At least how many explosions do you need to cause in order to vanish all the monsters?

Constraints

All input values are integers.

1 ≤ N ≤ 10^5

1 ≤ B < A ≤ 10^9

1 ≤ h_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N A B
h_1
h_2
:
h_N

Output

Print the minimum number of explosions that needs to be caused in order to vanish all the monsters.

Sample Input 1

4 5 3
8
7
4
2

Sample Output 1

2

You can vanish all the monsters in two explosion, as follows:

First, cause an explosion centered at the monster with 8 health. The healths of the four monsters become 3, 4, 1 and -1, respectively, and the last monster vanishes.

Second, cause an explosion centered at the monster with 4 health remaining. The healths of the three remaining monsters become 0, -1 and -2, respectively, and all the monsters are now vanished.

Sample Input 2

2 10 4
20
20

Sample Output 2

4

You need to cause two explosions centered at each monster, for a total of four.

Sample Input 3

5 2 1
900000000
900000000
1000000000
1000000000
1000000000

Sample Output 3

800000000

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AIZU {
	class PriorityQueue<T> where T : IComparable<T> {
		#region FieldAndInitialize
		//http://ufcpp.net/study/algorithm/col_heap.html
		List<T> me = new List<T>();
		List<int> Member = new List<int>();
		static Func<T, T, int> Sign = (i, j) => i.CompareTo(j);
		static Func<T, int> ID = i => i.GetHashCode();
		public PriorityQueue() { }
		public PriorityQueue(Func<T, T, int> F) { Sign = F; }
		public PriorityQueue(Func<T, int> F) { ID = F; }
		#endregion
		#region Control
		static void PushHeap(
			  List<T> array, List<int> member, Func<T, int> ID, T elem) {
			int N = array.Count;
			array.Add(elem);  //index of last equals to N
			member.Add(ID(elem));
			Ascend(array, member, N);
		}
		static T PopHeap(List<T> array, List<int> member, Func<T, int> ID) {
			int N = array.Count - 1;   //last index
			T peek = array[0];
			array[0] = array[N]; //paint out root
			array.RemoveAt(N);
			member[0] = member[N];
			member.RemoveAt(N);
			Descend(array, member, 0);
			return peek;
		}
		static void Ascend(List<T> array, List<int> member, int index) {
			int N = index;
			while (N != 0) {
				int i = (N - 1) >> 1;//i represents N's parent
				if (Sign(array[N], array[i]) > 0) { //N bigger than i
					T tmp = array[N]; array[N] = array[i]; array[i] = tmp;
					int tnp = member[N]; member[N] = member[i]; member[i] = tnp;
				}//swap
				N = i;   //update
			}
		}
		static void Descend(List<T> array, List<int> member, int index) {
			int N = array.Count;
			for (int i = index, j; (j = 2 * i + 1) < N;) {   //j is the left child of i
				if (j != N - 1 && Sign(array[j], array[j + 1]) < 0) //not last and  inferior to next
					j++;
				if (Sign(array[i], array[j]) < 0) { //i inf to j
					T tmp = array[j]; array[j] = array[i]; array[i] = tmp;
					int tnp = member[j]; member[j] = member[i]; member[i] = tnp;
				}//swap
				i = j;
			}
		}
		static void HeapReplace(List<T> array, List<int> member, Func<T, int> ID, int index, T NEW) {
			bool exceling = Sign(array[index], NEW) < 0;
			array[index] = NEW;
			member[index] = ID(NEW);
			if (exceling) Ascend(array, member, index);
			else Descend(array, member, index);
		}
		#endregion
		#region Data
		public void Push(T elem) { PushHeap(me, Member, ID, elem); }
		public T Pop() { return PopHeap(me, Member, ID); }
		public T Top { get { return me[0]; } }
		public int Count { get { return me.Count; } }
		public int HeapIndex(Func<T, bool> data) {
			return me.FindIndex(i => data(i));
		}
		public int HeapIndex(int d) { return Member.IndexOf(d); }
		public void Gain(T NEW, int index) {
			HeapReplace(me, Member, ID, index, NEW);
		}
		public T Access(int t) {
			if (t >= me.Count) return default(T);
			else return me[t];
		}
		#endregion
	}
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			int[] Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		#endregion
		
		static void Main(string[] args) {
			int[] I= cins();
			int N = I[0], A = I[1], B = I[2];
			PriorityQueue<int> P = new PriorityQueue<int>();
			for (int i = 0; i < N; i++) P.Push(cin());
			List<long> H = new List<long>();
			while (P.Count > 0) H.Add(P.Pop());
			long Limit = (long)Math.Ceiling((double)H.Max()/B);
			long lo = 0,hi = Limit+1;
			while (hi - lo > 1) {
				long mid = (hi + 1 + lo) / 2;
				long Bass = mid * B;
				int count = 0;
				while (count < H.Count()&&H[count] > Bass) count++;
				long Time = H.Take(count).Sum(s => (long)Math.Ceiling((double)(s-mid*B) / (A-B)));
				if (mid < Time) lo = mid;
				else hi = mid;
			}
			long Bassf = lo * B;
			int countf = 0;
			while (countf < H.Count() && H[countf] > Bassf) countf++;
			long Timef = H.Take(countf).Sum(s => (long)Math.Ceiling((double)(s - lo * B) / (A - B)));
			print(lo<Timef?hi:lo);
			Console.ReadLine();
		}
	}
}