307646: CF1389B. Array Walk
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Array Walk
题意翻译
你前面一共有 $n$ 个格子,每个格子都有它的分值 $a_x$。当你到达第 $x$ 个格子就能获得第 $x$ 个格子的得分 $a_x$。 初始时你站在第 $1$ 个格子,每一次移动你可以选择向左或向右,你不能连续向左移动两步或以上,特别地,向左移动的次数不能超过 $z$。 现在,请问你**正好**走了 $k$ 步后,最大得分是多少?题目描述
You are given an array $ a_1, a_2, \dots, a_n $ , consisting of $ n $ positive integers. Initially you are standing at index $ 1 $ and have a score equal to $ a_1 $ . You can perform two kinds of moves: 1. move right — go from your current index $ x $ to $ x+1 $ and add $ a_{x+1} $ to your score. This move can only be performed if $ x<n $ . 2. move left — go from your current index $ x $ to $ x-1 $ and add $ a_{x-1} $ to your score. This move can only be performed if $ x>1 $ . Also, you can't perform two or more moves to the left in a row. You want to perform exactly $ k $ moves. Also, there should be no more than $ z $ moves to the left among them. What is the maximum score you can achieve?输入输出格式
输入格式
The first line contains a single integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of testcases. The first line of each testcase contains three integers $ n, k $ and $ z $ ( $ 2 \le n \le 10^5 $ , $ 1 \le k \le n - 1 $ , $ 0 \le z \le min(5, k) $ ) — the number of elements in the array, the total number of moves you should perform and the maximum number of moves to the left you can perform. The second line of each testcase contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le 10^4 $ ) — the given array. The sum of $ n $ over all testcases does not exceed $ 3 \cdot 10^5 $ .
输出格式
Print $ t $ integers — for each testcase output the maximum score you can achieve if you make exactly $ k $ moves in total, no more than $ z $ of them are to the left and there are no two or more moves to the left in a row.
输入输出样例
输入样例 #1
4
5 4 0
1 5 4 3 2
5 4 1
1 5 4 3 2
5 4 4
10 20 30 40 50
10 7 3
4 6 8 2 9 9 7 4 10 9
输出样例 #1
15
19
150
56