#abc263f. F - Tournament
F - Tournament
Score : points
问题描述
名编号为 到 的人将参加一场剪刀石头布锦标赛。
比赛过程如下:
- 参赛者按照从左到右的顺序排列成一行,依次为参赛者 、参赛者 、、参赛者 。
- 设当前行的长度为 。对于每个 ,从左边数第 位和第 位参赛者进行一场比赛。然后,从行中移除这 名输家。这个过程重复 次。
其中,如果参赛者 赢得了恰好 场比赛,他们将获得 日元(日本货币)。赢得零场比赛的人不会得到任何奖励。在所有比赛结果都可以自由操纵的情况下,找出这 名参赛者可以获得的最大总金额。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
people, numbered to , will participate in a rock-paper-scissors tournament.
The tournament proceeds as follows:
- The participants are arranged in a row in the order Person , Person , , Person from left to right.
- Let be the current length of the row. For each , the -th and -th persons from the left play a game against each other. Then, the losers are removed from the row. This process is repeated times.
Here, if Person wins exactly games, they receive yen (Japanese currency). A person winning zero games receives nothing. Find the maximum possible total amount of money received by the people if the results of all games can be manipulated freely.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
2
2 5
6 5
2 1
7 9
Sample Output 1
15
The initial row of the people is .
If Person wins the game against Person , and Person wins the game against Person , the row becomes .
Then, if Person wins the game against Person , the row becomes , and the tournament ends.
Here, Person wins exactly game, and Person wins exactly games, so they receive yen in total, which is the maximum possible sum.
Sample Input 2
3
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
Sample Output 2
4
update @ 2024/3/10 11:08:16