Pro.ID22047 TitleArray Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22047 AC4 Submit9 Ratio44.44% 时间&空间限制描述Array is frequently used when we are programming. We are familiar with it. Here is a problem about array. Do enjoy it and try your best to solve it. Assume there is an array: a[1], a[2], …, a[n] ( a[i] is positive integer, 1 ≤ i ≤ n ) and a[i] ≤ a[j] ( 1 ≤ i < j ≤ n ) Now we define another array: b[1], b[2], …, b[[a[n]] b[i] = min{ v | a[v] ≥ i } , 1 ≤ i ≤ a[n] Finally, the problem is : given the value (n+a[n]), you have to find the maximum of (a[1] + a[2] + … + a[n] + b[1] + b[2] + … + b[a[n]] ). 输入The first line of the input is a positive integer T. T is the number of the test cases followed. Each test case contains an integer V ( 1 < V < 10000 ) which tell you the value (n+a[n]). There may be one ro several spaces before or after the integer. 输出Description Array is frequently used when we are programming. We are familiar with it. Here is a problem about array. Do enjoy it and try your best to solve it. Assume there is an array: a[1], a[2], …, a[n] ( a[i] is positive integer, 1 ≤ i ≤ n ) and a[i] ≤ a[j] ( 1 ≤ i < j ≤ n ) Now we define another array: b[1], b[2], …, b[[a[n]] b[i] = min{ v | a[v] ≥ i } , 1 ≤ i ≤ a[n] Finally, the problem is : given the value (n+a[n]), you have to find the maximum of (a[1] + a[2] + … + a[n] + b[1] + b[2] + … + b[a[n]] ). Input The first line of the input is a positive integer T. T is the number of the test cases followed. Each test case contains an integer V ( 1 < V < 10000 ) which tell you the value (n+a[n]). There may be one ro several spaces before or after the integer. Output The output of the program should consist of one line of output for each test case. The output of each test case only contains one integer M, M is the maximum of (a[1] + a[2] + … + a[n] + b[1] + b[2] + … + b[a[n]]). No any redundant spaces is needed. Sample Input 2 Sample Output 2 Source 样例输入2 样例输出2 作者 |