2017.1.20 Junior High School Department of the General Group of Simulation C Group of clothes drying

Source: Internet
Author: User
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. 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.