SB greedy, at the beginning also thought with two points, looked at the eyes Huang long blog, found himself sb ...
Minimum Road = Total number of cows/roads selected.
1#include <iostream>2#include <cstdio>3#include <algorithm>4 using namespacestd;5 intv[50010];6 intN,m,d,l,ans;7 intMain ()8 {9scanf"%d%d%d%d",&n,&m,&d,&l);Ten for(intI=1; i<=n;i++) scanf ("%d",&v[i]); OneSort (v+1, v+n+1); A for(intI=1; i<=n;i++) - { - intt=ans/m; the if(v[i]-t*d>=l) ans++; - } -printf"%d", ans); - return 0; +}
View Code DescriptionN cows numbered 1 to n are driving their cars to fly on the Nuedebia motorway. 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? Inputline 1th enters n,m,d,l four integers, followed by an integer of n lines for each line of SI. n<=50000Outputoutput up to 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.
Hintsource
Silver
"BZOJ1623" [Usaco2008 open]cow Cars cow rook greedy