题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1267 题意 田忌赛马,问最多能赢到多少钱?每局200元 思路 明显,把田忌的赛马排列一下,从速度高到低,齐王的也从高到低排列,当前田忌最高的赛马无法处理齐王最高的赛马,则换成田忌最慢的赛马去碰瓷. 难在如何处理平局-也就是速度相同的赛马. 有的时候本可以平局,但是最好先…
题意:田忌赛马,每胜一局就得200,负一局少200,问最多得多少钱. 析:贪心,如果最快的马比齐王的还快,就干掉它,如果最慢的马比齐王的马快,就干掉它,否则用最慢的马去和齐王最快的马比. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cma…
Tian Ji -- The Horse Racing Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 17662   Accepted: 5452 Description Here is a famous story in Chinese history. That was about 2300 years ago. General Tian Ji was a high official in the country Q…
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40477    Accepted Submission(s): 12148 Problem Description Here is a famous story in Chinese history. "That was about…
题目链接 题意 两人赛马,每居获胜得200,平局无事发生,输了也输200.求最优的策略使赢的钱最多. 分析 排序,从最快的开始比,若比不过,则用最弱的消耗最强的.模拟即可. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<algorithm> #include<cstring> #include <queue> #…
题目来源:1052 题目分析:题目说的权值匹配算法,有点误导作用,这道题实际是用贪心来做的. 主要就是规则的设定: 1.田忌最慢的马比国王最慢的马快,就赢一场 2.如果田忌最慢的马比国王最慢的马慢,就让这两匹马比一场,输一场 3.如果田忌最慢的马和国王最慢的马相等,就看 如果田忌最快的马比国王最快的马快,那就比一场,赢 如果田忌最快的马比国王最快的马慢,就让最慢的马和国王最快的马比一场,这一场输 如果田忌最快的马和国王最快的马相等,就看田忌最慢的马是否比国王最快的马慢,如果是,输一场,否则就是所…
题目链接:https://cn.vjudge.net/problem/HDU-1052 题意 田忌赛马问题扩展版 给n匹马,马的能力可以相同 问得分最大多少 思路 贪心做得还是太少,一开始一点思虑都没有的 这里稍微总结一下如何打开思路吧 从特殊位置开始考虑是否存在某种必然性,包括不限于序列首尾 若讨论难以进行,试着把这个讨论点展开,换个角度(或者换个特殊位置)讨论 首先排序 其次的关键是讨论尾元素是否必胜或必败,思考贪心 在一个关键是双方尾元素相同时,展开考虑首元素是否必胜或必败,思考贪心 当首…
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…
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 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 19   Accepted Submission(s) : 5 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Here is a…