#abc315c. C - Flavors
C - Flavors
Score : points
问题描述
我们有 个冰淇淋杯。
第 个冰淇淋杯的口味和美味程度分别为 和 (其中 是偶数)。
你需要从这 个冰淇淋杯中选择并吃掉两个。
你的满意度定义如下:
- 设 和 (满足 )为所吃掉的两个冰淇淋杯的美味程度。
- 如果两个冰淇淋杯口味不同,你的满意度为 。
- 否则,你的满意度为 。
求最大可获得的满意度。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have cups of ice cream.
The flavor and deliciousness of the -th cup are and , respectively ( is an even number).
You will choose and eat two of the cups.
Your satisfaction here is defined as follows.
- Let and () be the deliciousness of the eaten cups.
- If the two cups have different flavors, your satisfaction is .
- Otherwise, your satisfaction is .
Find the maximum achievable satisfaction.
Constraints
- All input values are integers.
- is even.
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
4
1 4
2 10
2 8
3 6
Sample Output 1
16
Consider eating the second and fourth cups.
- The second cup has a flavor of and deliciousness of .
- The fourth cup has a flavor of and deliciousness of .
- Since they have different flavors, your satisfaction is .
Thus, you can achieve the satisfaction of .
You cannot achieve a satisfaction greater than .
Sample Input 2
4
4 10
3 2
2 4
4 12
Sample Output 2
17
Consider eating the first and fourth cups.
- The first cup has a flavor of and deliciousness of .
- The fourth cup has a flavor of and deliciousness of .
- Since they have the same flavor, your satisfaction is .
Thus, you can achieve the satisfaction of .
You cannot achieve a satisfaction greater than .
update @ 2024/3/10 09:00:33