Tian Ji -- The Horse Racing 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…
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,…
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Here is a famous story in Chinese history. “That was about 2300 years ago. General Tian Ji was a high official in the cou…
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37056    Accepted Submission(s): 11153 Problem Description Here is a famous story in Chinese history. "That was about…
题目大意:田忌赛马问题,给出田忌和齐威王的马的数量$n$和每匹马的速度$v$,求田忌最多赢齐威王多少钱(赢一局得200,输一局扣200,平局不得不扣). 思路:贪心. 1.若田忌最慢的马可以战胜齐王最慢的马,那么就让它战胜那匹慢马,胜利场次加1.(田忌最慢马 > 齐王最慢马) 2.若田忌最慢的马不能战胜齐王最慢的马,那么它更加不能战胜其他的马,那就让它输给齐王最快的马,失败场次加1.(田忌最慢马 < 齐王最快马) 3.若田忌最慢的马与齐王最慢的马速度相等.此时,打平是错误的. 因为自己的快马很…
Tian Ji -- The Horse Racing 田忌赛马,还是English,要不是看题目,我都被原题整懵了,直接上Chinese吧 Descriptions: 田忌和齐王赛马,他们各有n匹马,依次派出一匹马比赛,赢了加200,输了减200,平局不加钱,问如何安排马的出场顺序,使得田忌赢的钱最多 Input 输入最多包含 50 组测试数据.对于每组测试数据,第一行包括一个正整数 n (n ≤ 1000),表示每一方的马的数目.第二行中的 n 个整数,表示田忌的马的速度.第三行中的 n 个…
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18291    Accepted Submission(s): 5327 Problem Description Here is a famous story in Chinese history. "That was about 2…
Tian Ji -- The Horse Racing HDU - 1052 (有平局的田忌赛马,田忌赢一次得200块,输一次输掉200块,平局不得钱不输钱,要使得田忌得到最多(如果只能输就输的最少)) 首先,实际是要求两人马的配对关系.那么不妨设齐王是按从快到慢的顺序出马的.因此先将齐王的马排序. 关键在于田忌最慢的马,能先赢就先赢,不能赢就去消耗齐王最快的马,然后再来考虑最快的马,能先赢就先赢,不能赢说明现在田忌和齐王最快的马和最慢的马都相等,再来考虑把田忌最慢的马和齐王最快的马比较. 可以…
算法分析: 这个问题很显然可以转化成一个二分图最佳匹配的问题.把田忌的马放左边,把齐王的马放右边.田忌的马A和齐王的B之间,如果田忌的马胜,则连一条权为200的边:如果平局,则连一条权为0的边:如果输,则连一条权为-200的边. 然而我们知道,二分图的最佳匹配算法的复杂度很高,无法满足N=2000的要求. 我们不妨用贪心思想来分析一下问题.因为田忌掌握有比赛的“主动权”,他总是根据齐王所出的马来分配自己的马,所以这里不妨认为齐王的出马顺序是按马的速度从高到低出的.由这样的假设,我们归纳出如下贪心…
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11572    Accepted Submission(s): 3239 Problem Description Here is a famous story in Chinese history. "That was about 2…