#abc267c. C - Index × A(Continuous ver.)
C - Index × A(Continuous ver.)
Score : points
问题描述
给定一个长度为 的整数序列 。
求出该序列中长度为 的连续子数组 ,使得 的最大值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given an integer sequence of length .
Find the maximum value of for a contiguous subarray of of length .
Notes
A contiguous subarray of a number sequence is a sequence that is obtained by removing or more initial terms and or more final terms from the original number sequence.
For example, and are contiguous subarrays of , but and are not contiguous subarrays of .
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
4 2
5 4 -1 8
Sample Output 1
15
When , we have $\displaystyle \sum_{i=1}^{M} i \times B_i = 1 \times (-1) + 2 \times 8 = 15$. Since it is impossible to achieve or a larger value, the solution is .
Note that you are not allowed to choose, for instance, .
Sample Input 2
10 4
-3 1 -4 1 -5 9 -2 6 -5 3
Sample Output 2
31
update @ 2024/3/10 11:16:28