Little IR12660 arrived in Tecuci, land of legendary mustard sauce. He is currently at a mustard fair, where various mustard sauces are being presented. While the mustard sauces were spinning around on a conveyor belt, he came up with the following idea:
You are given an array $$$A$$$ of length $$$n$$$ and an integer $$$k$$$. You are allowed to perform at most $$$k$$$ cyclic shifts on any subarray of $$$A$$$.
Determine the maximum sum of a contiguous subarray that can be obtained after performing at most $$$k$$$ such cyclic shifts.
A cyclic shift in any direction on a subarray means:
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
Each test case consists of:
It is guaranteed that the sum of $$$n \cdot k$$$ across all testcases does not exceed $$$10^6$$$ and the sum of $$$n$$$ across all testcases does not exceed $$$10^6$$$.
For each test case, output a single integer — the maximum sum of a contiguous subarray that can be obtained after performing at most $$$k$$$ cyclic shifts.
45 2-1 2 -3 4 -57 34 -2 1 3 -1 -3 26 1-1 -1 2 -1 -1 -15 5-1 -1 -1 -1 -1
6 10 2 -1