You are given an array 𝑎1,𝑎2,…,𝑎𝑛 of positive integers. You can color some elements…
- User
You are given an array 𝑎1,𝑎2,…,𝑎𝑛 of positive integers.
You can color some elements of the array red, but there cannot be two adjacent red elements (i.e., for 1≤𝑖≤𝑛−1 , at least one of 𝑎𝑖 and 𝑎𝑖+1 must not be red).
Your score is the maximum value of a red element plus the number of red elements. Find the maximum score you can get.
Input Each test contains multiple test cases. The first line contains the number of test cases 𝑡 (1≤𝑡≤500 ). The description of the test cases follows.
The first line of each test case contains a single integer 𝑛 (1≤𝑛≤100 ) — the length of the array.
The second line of each test case contains 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛 (1≤𝑎𝑖≤1000 ) — the given array.
Output For each test case, output a single integer: the maximum possible score you can get after coloring some elements red according to the statement.
solve using normal greedy or brute force in c++
- Assistant