您当前的位置: 首页 > 

钟钟终

暂无认证

  • 2浏览

    0关注

    233博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

第二周--贪心题解(P)

钟钟终 发布时间:2021-03-19 22:53:40 ,浏览量:2

题P: Many graduate students of Peking University are living in Wanliu Campus, which is 4.5 kilometers from the main campus – Yanyuan. Students in Wanliu have to either take a bus or ride a bike to go to school. Due to the bad traffic in Beijing, many students choose to ride a bike.

We may assume that all the students except “Charley” ride from Wanliu to Yanyuan at a fixed speed. Charley is a student with a different riding habit – he always tries to follow another rider to avoid riding alone. When Charley gets to the gate of Wanliu, he will look for someone who is setting off to Yanyuan. If he finds someone, he will follow that rider, or if not, he will wait for someone to follow. On the way from Wanliu to Yanyuan, at any time if a faster student surpassed Charley, he will leave the rider he is following and speed up to follow the faster one.

We assume the time that Charley gets to the gate of Wanliu is zero. Given the set off time and speed of the other students, your task is to give the time when Charley arrives at Yanyuan. Input There are several test cases. The first line of each case is N (1 >a[i].b; a[i].c=a[i].b+4.5/a[i].a1*1.0*3600; } sort(a,a+n,cmp); int j,i; for(i=0;i=0) {j=a[i].c;break;} } if(j!=a[i].c) j+=1; cout

关注
打赏
1664378814
查看更多评论
立即登录/注册

微信扫码登录

0.0346s