英文题翻译3

Tian Ji -- The Horse Racing | JXNUOJ

Here is a famous story in Chinese history.
"That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play horse racing with the king and others."
"Both of Tian and the king have three horses in different classes, namely, regular, plus, and super. The rule is to have three rounds in a match; each of the horses must be used in one round. The winner of a single round takes two hundred silver dollars from the loser."
"Being the most powerful man in the country, the king has so nice horses that in each class his horse is better than Tian's. As a result, each time the king takes six hundred silver dollars from Tian."
"Tian Ji was not happy about that, until he met Sun Bin, one of the most famous generals in Chinese history. Using a little trick due to Sun, Tian Ji brought home two hundred silver dollars and such a grace in the next match."
"It was a rather simple trick. Using his regular class horse race against the super class from the king, they will certainly lose that round. But then his plus beat the king's regular, and his super beat the king's plus. What a simple trick. And how do you think of Tian Ji, the high ranked official in China?"

Were Tian Ji lives in nowadays, he will certainly laugh at himself. Even more, were he sitting in the ACM contest right now, he may discover that the horse racing problem can be simply viewed as finding the maximum matching in a bipartite graph. Draw Tian's horses on one side, and the king's horses on the other. Whenever one of Tian's horses can beat one from the king, we draw an edge between them, meaning we wish to establish this pair. Then, the problem of winning as many rounds as possible is just to find the maximum matching in this graph. If there are ties, the problem becomes more complicated, he needs to assign weights 0, 1, or -1 to all the possible edges, and find a maximum weighted perfect matching...
However, the horse racing problem is a very special case of bipartite matching. The graph is decided by the speed of the horses --- a vertex of higher speed always beat a vertex of lower speed. In this case, the weighted bipartite matching algorithm is a too advanced tool to deal with the problem.
In this problem, you are asked to write a program to solve this special case of matching problem.

The input consists of up to 50 test cases. Each case starts with a positive integer n (n <= 1000) on the first line, which is the number of horses on each side. The next n integers on the second line are the speeds of Tian’s horses. Then the next n integers on the third line are the speeds of the king’s horses. The input ends with a line that has a single 0 after the last test case.

For each input case, output a line containing a single number, which is the maximum money Tian Ji will get, in silver dollars.

翻译:

这是一个在中国历史上很著名的故事。在2300年前,田忌将军在齐王朝是一个高官。他喜欢和王及其他人赛马。田忌和王都有三种不同种的马,即,普通,中等,高等。比赛规则是在一场比赛中有三个回合,每匹马都将被用在三个回合中。每一回合的胜者都可以得到败者的200银元。作为这个国家权力至高无上的人,在三个等级的马中,王都拥有比田忌更好的马。所以,每次王都从田忌那里拿走600银元。对此,田忌很不开心,直到他遇到孙膑,中国历史上最有名的将军之一。由于孙膑教的小技巧,田忌在接下来的比赛中赢得200银元和恩典。这是一个相当简单的技巧,用他最低等的马与王最高等的马比赛,他肯定会输掉这一场比赛。但是,当他用他中等的马击败王低等的马,高等的马击败王中等的马。多么简单的策略!你怎样认为中国的高官田忌?如果田忌生活在现在,他一定会嘲笑他自己。甚至,如果他现在参加 ACM 比赛,他可能会发现这个赛马问题会被简单的认为是找到最大的二分图中的匹配。一边画田忌的马,另一边画王的马。无论何时田忌的其中一匹马可以击败王的马,我们就在它们之间画一条边界,意味着我们希望建立这对。那么,尽可能多的赢得回合的问题就变成了找到最大的二分图中的匹配。如果有关系,问题就变得更复杂,他需要对所有可能的边界分配权重0,1, 或者 -1 ,然后找到最大加权完美匹配...然而,赛马问题是二分匹配中一个很特殊的情况。图表取决于马的速度---较高速度的顶点总是击败较低速度的顶点,在这种情况下,加权二分匹配算法是处理该问题的一种过于先进的工具。在这个问题中,你被要求编写一个程序来解决这个匹配问题的特殊情况。

输入包含多达 50 个测试用例。 每个测试用例都以第一行的正整数 n (n <= 1000) 开头,表示每边的马匹数量。 第二行接下来的 n 个整数是田忌的马的速度。 第三行接下来的 n 个整数是王的马的速度。 输入以在最后一个测试用例之后有一个 0 的行结束。

对于每个输入用例,输出一个包含单个数字的行,表示田忌将获得的最大金钱,以银元为单位。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值