经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Medals

📝 题解 🔵 仅限 C++
题目描述
<p>At the Olympic Games, countries are ranked according to the number of medals their athletes won. However, there is more than one possible way of ranking countries by their medals. In Europe, for example, countries are first ranked by the number of gold medals their athletes won. Ties are broken by looking at silver medals, and then at bronze medals. In Canada, however, because Canadian athletes do not win very many gold medals, countries are ranked by the overall number of medals won, giving the same weight to gold, silver, and bronze medals. <br /> <br /> In general, a ranking scheme can be thought of as a vector of positive weights. This vector is multiplied with the vector of medals won by each country, and the scalar product of the two vectors defines the score of the respective country, which is then used to produce the ranking. In this general scheme, the European ranking technique corresponds to the weight vector <i>(10<sup>20</sup>, 10<sup>10</sup>, 1)</i>, whereas the Canadian method corresponds to the vector <i>(1, 1, 1)</i>. <br /> <br /> In this problem, you will only need to consider weight vectors of the form <i>(1/n<sup>j</sup>, 1/n<sup>k</sup>, 1/n<sup>l</sup>)</i>, where <i>n</i> is the total number of medals won by all athletes in the Olympic Games, and <i>j</i>, <i>k</i>, and <i>l</i> are integers. <br /> <br /> Given a list of countries and the number of gold, silver, and bronze medals won by each country, print the line</p> <blockquote> <tt>Canada wins!</tt> </blockquote> <p>if there is a weight vector of the above form such that Canada ranks first according to the ranking scheme defined by that vector. Print the line</p> <blockquote> <tt>Canada cannot win.</tt> </blockquote> <p>if no such vector exists.</p> <br /> <br /> <p>The input contains multiple test cases. Each test case starts with an integer</p> <i>c</i> <p>, the number of countries to follow. Each of the following</p> <i>c</i> <p>lines contains the name of a country and three integers</p> <i>g</i> <p>,</p> <i>s</i> <p>, and</p> <i>b</i> <p>&ndash; the number of gold, silver, and bronze medals won by the country. The last test case has</p> <i>c = 0</i> <p>and must not be processed. It is guaranteed that each test case contains at most 20 different countries and that the total number of medals smaller than 100. Country names do not contain whitespace characters.</p>
输入格式
输出格式
样例
样例输入 1
2 Canada 3 2 1 USA 1 2 3 2 USA 2 2 2 Canada 1 1 1 0
样例输出 1
Canada wins! Canada cannot win.
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用