外外贸网站推广方案,网站案例代码,wordpress任意电脑编辑,北京网络营销外包公司哪家好正题 题目大意 nnn个横向道#xff0c;若干辆车#xff0c;每辆车速度恒定#xff0c;给出方向位置长度。
过马路的速度#xff0c;最早开始时间#xff0c;最晚开始时间。求最长的可以通过马路的时间段。 解题思路
计算出每辆车限制的时间区间#xff0c;然后排序找到…正题 题目大意
nnn个横向道若干辆车每辆车速度恒定给出方向位置长度。
过马路的速度最早开始时间最晚开始时间。求最长的可以通过马路的时间段。 解题思路
计算出每辆车限制的时间区间然后排序找到一个最长为空的区间。 codecodecode
#includecstdio
#includecstring
#includealgorithm
#includeiostream
#includecmath
using namespace std;
const int N1e510;
struct node{double x;int w;
}a[N*2];
int n,cnt;
double w,u,v,st,tt,ans;
bool cmp(node x,node y)
{return x.xy.x;}
int main()
{scanf(%d%lf%lf%lf%lf%lf,n,w,u,v,st,tt);for(int i1;in;i){char op;int m;cinopm;for(int j1;jm;j){double l,p,sT,eT;scanf(%lf%lf,l,p);if(opE) sT-p/u,eT(l-p)/u;if(opW) sTp/u,eT(pl)/u;if(sTeT) swap(sT,eT);sT-i*(w/v);eT-(i-1)*(w/v);a[cnt](node){sT,1};a[cnt](node){eT,-1};}}sort(a1,a1cnt,cmp);int now0;ansmax(a[1].x-st,tt-a[cnt].x);for(int i1;icnt;i){nowa[i].w;if(now0)ansmax(ans,min(a[i1].x,tt)-max(a[i].x,st));}printf(%.8lf,ans);
}