#abc100d. D - Patisserie ABC
D - Patisserie ABC
Score: points
问题描述
高桥成为了一名糕点师,并开设了一家名为“La Confiserie d'ABC”的店铺以庆祝AtCoder新手比赛100期。
这家店铺出售种蛋糕。
每种蛋糕都有三个参数:“美观度”、“美味度”和“受欢迎度”。第种蛋糕的美观度为,美味度为,受欢迎度为。
这些数值可能为零或负数。
玲珑决定在这里购买块蛋糕。他将按照以下方式选择蛋糕组合:
- 不要选择两种或以上同种类的蛋糕。
- 在上述条件下,选择能使(总美观度的绝对值)+(总美味度的绝对值)+(总受欢迎度的绝对值)最大化的蛋糕组合。
找出玲珑所选蛋糕组合中,(总美观度的绝对值)+(总美味度的绝对值)+(总受欢迎度的绝对值)的最大可能值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100.
The shop sells kinds of cakes.
Each kind of cake has three parameters "beauty", "tastiness" and "popularity". The -th kind of cake has the beauty of , the tastiness of and the popularity of .
These values may be zero or negative.
Ringo has decided to have pieces of cakes here. He will choose the set of cakes as follows:
- Do not have two or more pieces of the same kind of cake.
- Under the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).
Find the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.
Constraints
- is an integer between and (inclusive).
- is an integer between and (inclusive).
- are integers between and (inclusive).
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.
Sample Input 1
5 3
3 1 4
1 5 9
2 6 5
3 5 8
9 7 9
Sample Output 1
56
Consider having the -nd, -th and -th kinds of cakes. The total beauty, tastiness and popularity will be as follows:
- Beauty:
- Tastiness:
- Popularity:
The value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is . This is the maximum value.
Sample Input 2
5 3
1 -2 3
-4 5 -6
7 -8 -9
-10 11 -12
13 -14 15
Sample Output 2
54
Consider having the -st, -rd and -th kinds of cakes. The total beauty, tastiness and popularity will be as follows:
- Beauty:
- Tastiness:
- Popularity:
The value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is . This is the maximum value.
Sample Input 3
10 5
10 -80 21
23 8 38
-94 28 11
-26 -2 18
-69 72 79
-26 -86 -54
-72 -50 59
21 65 -32
40 -94 87
-62 18 82
Sample Output 3
638
If we have the -rd, -th, -th, -th and -th kinds of cakes, the total beauty, tastiness and popularity will be , and , respectively.
The value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is . This is the maximum value.
Sample Input 4
3 2
2000000000 -9000000000 4000000000
7000000000 -5000000000 3000000000
6000000000 -1000000000 8000000000
Sample Output 4
30000000000
The values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers.
update @ 2024/3/10 17:18:55