#K10391. Maximum Subsequence Sum After Rotation
Maximum Subsequence Sum After Rotation
Maximum Subsequence Sum After Rotation
You are given an array of n integers and an integer k representing the number of positions to rotate the array to the right. After performing the rotation, your task is to determine the maximum subsequence sum from the rotated array.
Under the constraints of this problem, all array elements are non-negative. Therefore, the maximum subsequence sum can be obtained by summing all the elements of the rotated array. In mathematical terms, if the rotated array is \(a_1, a_2, \ldots, a_n\), then the answer is given by:
[ S = \sum_{i=1}^{n} a_i ]
Note: Although the term "subsequence" is used in the statement, under the given constraints the correct answer is simply the sum of all numbers after the rotation.
inputFormat
The input is received from stdin and has the following format:
n k a1 a2 ... an
Here, n is the number of elements in the array, k is the number of positions to rotate the array to the right, and the second line contains n space-separated integers representing the array.
outputFormat
Output a single integer to stdout: the maximum subsequence sum of the array after the rotation.
## sample5 2
1 2 3 4 5
15