#arc174a. A - A Multiply
A - A Multiply
Score: points
问题陈述
给定一个长度为 的整数序列 ,以及一个整数 。 在执行以下操作 最多一次 后,找出 中元素的最大可能和:
- 指定整数 和 ,使得 ,并将 每个元素乘以 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given an integer sequence of length , , and an integer .
Find the maximum possible sum of the elements in after performing the following operation at most once:
- Specify integers and such that , and multiply each of by .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
5 2
-10 10 20 30 -20
Sample Output 1
90
In this input, .
After performing the operation once specifying and , will be .
Here, the sum of the elements in is , which is the maximum value achievable.
Sample Input 2
5 1000000
-1 -2 -3 -4 -5
Sample Output 2
-15
In this input, .
Without performing the operation, the sum of the elements in is , which is the maximum value achievable.
Sample Input 3
9 -1
-9 9 -8 2 -4 4 -3 5 -3
Sample Output 3
13