ferry

所属分类:控制台编程
开发工具:Visual C++
文件大小:2KB
下载次数:36
上传日期:2011-10-27 13:35:39
上 传 者ljpnndd
说明:  某汽车轮渡口,有n辆车要过河。n辆车只有两种要么是客车,要么是货车。已知过江渡船每次能载10辆车,从0分开始每10分钟来一次(即0分一辆,10分一辆,以此类推)。又知上渡船要遵守下述规定:若x分来了一辆渡船所有到大渡口时间<=x分且还没过河的车辆才可能上船,且客车先于货车上船,每上4辆客车必上1辆货车,这时若没有货车就上客车,若没有客车就上货车。试编写一个程序,模拟渡口的管理,统计客车和货车的平均等待时间。 输入格式: 第一行一个正整数n(1000 <= n <= 1000 000),表示要过江的车辆总数。 第二行到n+1行每行两个非负整数type,time(0 <= time <= 1000 000),表示time分到达渡口的车是type类型,type为0表示客车,为1表示货车,时间从0开始计,且按到达时间先后给出数据。 输出格式: 一行两个保留两位的小数(四舍五入)carWaitTime,trunkWaitTime以空格分开,carWaitTime表示客车的平均等待时间,trunkWaitTime表示货车的平均等待时间。
(A car ferry port, there are n vehicles to cross the river. n is either the car only two buses, either truck. Known across the river ferry can carry 10 cars each, starting from 0 to once every 10 minutes (ie, 0 a, 10 a, and so on). They know on the ferry to comply with the following requirements: if x points to a car ferry to the large ferry all the time <= x min and it could not cross the river on board the vehicle, and passenger vehicles on board prior to each on the 4 buses will be on a truck, then if there is no vehicle on the bus, if there is no passenger on the truck. Try to write a program to simulate the management of the ferry, bus and truck statistical average waiting time. Input formats: The first line of a positive integer n (1000 <= n <= 1000 000), said the total number of vehicles to cross the river. The second line to the n 1 line per line two non-negative integer type, time (0 <= time <= 1000 000), said the time points to reach the ferry car is of ty)

文件列表:
ferry.cpp (3987, 2011-10-14)

近期下载者

相关文件


收藏者