| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 616 人关注过本帖
标题:分析程序,谢谢
只看楼主 加入收藏
qiudaowen1
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-24
收藏
 问题点数:0 回复次数:2 
分析程序,谢谢

程序在附件,这里是题目:
Problem
John is moving to the penthouse of a tall sky-scraper. He packed all his stuff in boxes and drove them to the entrance of the building on the ground floor. Unfortunately the elevator is out of order, so the boxes have to be moved up the stairs.
Luckily John has a lot of friends that want to help carrying his boxes up. They all walk the stairway at the same speed of 1 floor per minute, regardless of whether they carry a box or not. The stairway however is so narrow that two persons can't pass each other on it. Therefore they deciced to do the following: someone with a box in his hands is always moving up and someone empty-handed is always moving down. When two persons meet each other somewhere on the stairway, the lower one (with a box) hands it over to the higher one (without a box). (And then the lower one walks down again and the higher one walks up.) The box exchange is instantaneous. When someone is back on the ground floor, he picks up a box and starts walking up. When someone is at the penthouse, he drops the box and walks down again.

After a while the persons are scattered across the stairway, some of them with boxes in their hands and some without. There are still a number of boxes on the ground floor and John is wondering how much more time it will take before all the boxes are up. Help him to find out!

Input
One line with a positive number: the number of test cases. Then for each test case:

One line with three numbers N, F, B with 1 ≤ N,F ≤ 1000 and 1 ≤ B ≤ 1000000: the number of persons, the number of floors (0=ground floor, F=penthouse) and the number of boxes that are still on the ground floor.

N lines with two numbers fi and bi with 0 ≤ fi ≤ F and bi = 0 or bi = 1: the floors where the persons are initially and whether or not they have a box in their hands (1=box, 0=no box).

Output
One line with the amount of time (in minutes) it will take to get all the remaining boxes to the penthouse.

Sample input
2
3 10 5
0 0
0 0
0 0
2 5 1
2 1
3 0


Sample output
30
8

D5XdtPbO.txt (6.77 KB) 分析程序,谢谢


搜索更多相关主题的帖子: 分析 penthouse building carrying 
2007-09-19 20:17
qiudaowen1
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2007-4-24
收藏
得分:0 
忘记说明,通过编译,但提交时不能通过,实在看不出是什么问题。
2007-09-19 20:19
ydq1
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-9-18
收藏
得分:0 

题目简单 但是看不懂 郁闷

2007-09-19 21:46
快速回复:分析程序,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017693 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved