1623: [Usaco2008 open]cow Cars Cow Rook

Source: Internet
Author: User

1623: [Usaco2008 open]cow Cars Cow speed time limit:5 Sec Memory limit:64 MB
submit:291 solved:201
[Submit] [Status] [Discuss] n cows with a Description number of 1 to n are driving their cars to fly on the Nuedebia highway. The motorway has M (1≤m≤n) lanes.    Cow I has an own speed limit of Si (l≤si≤1,000,000). After a bad driving accident, the cows become very careful to avoid collisions. In each lane, if a cow I in front of a K cow drive, the cow I speed limit will drop k*d units, that is, her speed will not exceed SI-KD (o≤d≤5000), of course, if the number is negative, then her speed will be 0. Nuedebia's high-speed road law stipulates that vehicles travelling on highways must not be less than/(1≤l≤1,000,000). So, do you calculate how many cows can travel on the freeway? Input line 1th enters n,m,d,l four integers, followed by an integer of n lines for each line of SI. N<=50000output output How many cows can travel on the freeway. Sample Input3 1 1 5//Three the cow drove past a passage. When a cow enters the channel, its speed V becomes v-d*x (X represents how many cows are in front of it), and it slows down, and the speed cannot be less than L
5
7
5

INPUT DETAILS:

There is three cows with one lane-drive in, a speed decrease
of 1, and a minimum speed limit of 5.

Sample Output2

OUTPUT DETAILS:

Cows is possible, by putting either cow with speed 5 first and the cow
With Speed 7 second.

HINT Source

Silver

The puzzle: Good greedy!!! I really don't understand why so many people still get a bunch of ...

1 var2 I,j,k,l,m,n,ans:longint;3A:Array[0..100000] ofLongint;4 procedureSwapvarx,y:longint); inline;5           varZ:longint;6           begin7z:=x;x:=y;y:=Z;8           End;9 proceduresort (l,r:longint); inline;Ten           varI,j,x,y:longint; One           begin Ai:=l;j:=r;x:=a[(L+r)Div 2]; -                Repeat -                       whileA[i]<x DoInc (i); the                       whileA[j]>x DoDec (j); -                      ifI<=j Then -                         begin - swap (a[i],a[j]); + Inc (I);d EC (j); -                         End; +                untilI>J; A                ifI<r Thensort (i,r); at                ifL<j Thensort (l,j); -           End; - begin - readln (n,m,k,l); -       fori:=1  toN Doreadln (A[i]); -Sort1, n); in       fori:=1  toN Do if(A[i]-(ansDivm) *k) >=l ThenInc (ANS); - writeln (ans); to Readln; + End.

1623: [Usaco2008 open]cow Cars Cow Rook

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.