Original question:
http://172.16.0.132/junior/#contest/SHOW/1370/1 topic Description:
After washing your clothes, you should dry your clothes. Clothes in the natural conditions with 1 units of time can be dried to dry a point of humidity. Now buy 1 dryer, using the dryer can let you use 1 units of time to make 1 pieces of clothes in addition to the natural drying of a point humidity, but also dry b point humidity, but in 1 units of time can only 1 pieces of clothing use.
n Clothes for a variety of reasons and not as wet, now tell you the humidity of each dress, you need to find the minimum time to dry all clothes (humidity is 0 dry). Input:
The first line n,a,b;
The next N lines, one number per line, indicate the humidity of the garment (1<= humidity, a,b<=500000,1<=n<=500000). Output:
An integer line representing the minimum time. Sample Input:
3 2 1
1
2
3 Sample output:
1 data range limits:
(1<= humidity, a,b<=500000,1<=n<=500000) Sample analysis:
In the 1th unit time, the machine handles the 3rd piece of clothing, in addition, all the clothes naturally dried 2. Analysis:
The two-point answer implementation:
var n,a,b,i,l,r,ans,t,y,mid:longint;
D:array[0..500001]of Longint;
function PD (X:longint): boolean;
Begin t:=0;
For I:=1 to n does begin if d[i]<=a*x then continue;
Y:=d[i]-a*x;
t:=t+ (y+b-1) div b;
End
If T<=x then exit (true) else exit (false);
End
Begin assign (input, ' dry.in '); reset (input);
Assign (output, ' dry.out '); rewrite (output);
READLN (N,A,B);
For I:=1 to N do readln (D[i]); L:=1;
r:=5000001;
While l<=r do begin mid:= (l+r) SHR 1;
If PD (mid) then BEGIN r:=mid-1;
Ans:=mid;
End Else l:=mid+1;
End
Writeln (ANS);
Close (input); close (output); End.