#abc218h. H - Red and Blue Lamps
H - Red and Blue Lamps
Score : points
问题描述
有 盏灯,编号为从 到 ,它们排成一行。你需要将其中 盏灯点亮为红色,其余 盏灯点亮为蓝色。
对于每个 ,如果第 盏灯与第 盏灯的颜色不同,则会获得奖励 。
请确定通过有效决策灯具颜色可以获得的最大总奖励。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are lamps numbered through arranged in a row. You are going to light of them in red and in blue.
For each , a reward of is given if Lamp and Lamp light up in different colors.
Find the maximum total reward that can be obtained by efficiently deciding the colors of the lamps.
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
6 2
3 1 4 1 5
Sample Output 1
11
Lighting up Lamps in red and Lamps in blue yields a total reward of .
You cannot get any more, so the answer is .
Sample Input 2
7 6
2 7 1 8 2 8
Sample Output 2
10
Lighting up Lamps in red and Lamp in blue yields a total reward of .
Sample Input 3
11 7
12345 678 90123 45678901 234567 89012 3456 78901 23456 7890
Sample Output 3
46207983
update @ 2024/3/10 09:39:57