前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >1623: [Usaco2008 Open]Cow Cars 奶牛飞车

1623: [Usaco2008 Open]Cow Cars 奶牛飞车

作者头像
HansBug
发布2018-04-11 10:16:28
5110
发布2018-04-11 10:16:28
举报
文章被收录于专栏:HansBug's LabHansBug's Lab

1623: [Usaco2008 Open]Cow Cars 奶牛飞车

Time Limit: 5 Sec  Memory Limit: 64 MB

Submit: 291  Solved: 201

[Submit][Status][Discuss]

Description

  编号为1到N的N只奶牛正各自驾着车打算在牛德比亚的高速公路上飞驰.高速公路有M(1≤M≤N)条车道.奶牛i有一个自己的车速上限Si(l≤Si≤1,000,000).

    在经历过糟糕的驾驶事故之后,奶牛们变得十分小心,避免碰撞的发生.每条车道上,如果某一只奶牛i的前面有K只奶牛驾车行驶,那奶牛i的速度上限就会下降K*D个单位,也就是说,她的速度不会超过Si - kD(O≤D≤5000),当然如果这个数是负的,那她的速度将是0.牛德比亚的高速会路法规定,在高速公路上行驶的车辆时速不得低于/(1≤L≤1,000,000).那么,请你计算有多少奶牛可以在高速公路上行驶呢?

Input

第1行输入N,M,D,L四个整数,之后N行每行一个整数输入Si.

N<=50000

Output

    输出最多有多少奶牛可以在高速公路上行驶.

Sample Input

3 1 1 5//三头牛开车过一个通道.当一个牛进入通道时,它的速度V会变成V-D*X(X代表在它前面有多少牛),它减速后,速度不能小于L 5 7 5 INPUT DETAILS: There are three cows with one lane to drive on, a speed decrease of 1, and a minimum speed limit of 5.

Sample Output

2 OUTPUT DETAILS: Two cows are possible, by putting either cow with speed 5 first and the cow with speed 7 second.

HINT

Source

Silver

题解:说好的贪心嘛!!!实在不明白为啥那么多人还弄个堆。。。

 1 var
 2    i,j,k,l,m,n,ans:longint;
 3    a:array[0..100000] of longint;
 4 procedure swap(var x,y:longint);inline;
 5           var z:longint;
 6           begin
 7                z:=x;x:=y;y:=z;
 8           end;
 9 procedure sort(l,r:longint);inline;
10           var i,j,x,y:longint;
11           begin
12                i:=l;j:=r;x:=a[(l+r) div 2];
13                repeat
14                      while a[i]<x do inc(i);
15                      while a[j]>x do dec(j);
16                      if i<=j then
17                         begin
18                              swap(a[i],a[j]);
19                              inc(i);dec(j);
20                         end;
21                until i>j;
22                if i<r then sort(i,r);
23                if l<j then sort(l,j);
24           end;
25 begin
26      readln(n,m,k,l);
27      for i:=1 to n do readln(a[i]);
28      sort(1,n);
29      for i:=1 to n do if (a[i]-(ans div m)*k)>=l then inc(ans);
30      writeln(ans);
31      readln;
32 end.
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-04-06 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1623: [Usaco2008 Open]Cow Cars 奶牛飞车
  • Description
  • Input
  • Output
  • Sample Input
  • Sample Output
  • HINT
  • Source
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档