当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3056:The Bavarian Beer Party

题目描述
The professors of the Bayerische Mathematiker Verein have their annual party in the local Biergarten. They are sitting at a round table each with his own pint of beer. As a ceremony each professor raises his pint and toasts one of the other guests in such a way that no arms cross.

Figure 2: Toasting across a table with eight persons:no arms crossing(left), arms crossing(right)

We know that the professors like to toast with someone that is drinking the same brand of beer, and we like to maximize the number of pairs of professors toasting with the same brand , again without crossing arms. Write an algorithm to do this, keeping in mind that every professor should take part in the toasting.
输入解释
The frist line of the input contains a single number: the number of test cases to follow. Each test case has the following format:
One line with an even number p, satisfying 2 <= p <= 1000: the number of participants
One line with p integers (separated by single spaces) indicating the beer brands fro the consecutive professors( in clockwise order, starting at an arbitrary position). Each value is between 1 and 100 (boudaries included).
输出解释
For every test case in the input, the output should contain a single number on a single line: the maximum number of non-intersecting toasts of the same beer brand for this test case.
输入样例
2
6
1 2 2 1 3 3
22
1 7 1 2 4 2 4 9 1 1 9 4 5 9 4 5 6 9 2 1 2 9
输出样例
3
6

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3056

最后修改于 2020-10-29T06:51:25+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000 65536