2609. WOJ

单点时限: 2.0 sec

内存限制: 256 MB

Alex likes solving problems on WOJ (http://acm.whu.edu.cn/oak). As we all know, a beautiful balloon will appears when a

problem is solved. Alex loves balloons, especially when they’re in a consecutive column, from which he can get a sense of

accomplishment.

Problems on WOJ have a variety of difficulties. Hard problems cost more time, while easy ones may be “killed in 1

second”. Now we know that WOJ has N problems, numbered from 1 to N. Alex calls the solved problems in one

consecutive column as a “successful string”. The length of a successful string is the number of problems it contains. Also

he defines the value of a successful string as the square of the string’s length. Alex hopes to solve a certain number of

problems in M time, so he can get some successful strings, now he wants to maximize the sum of all the strings’ value.

输入格式

The input consists of multiple test cases. The first line of input contains an integer T, which is the number of test cases.

The input consists of several test cases. Each test case starts with a line containing two integers N and M.

Each of the following N lines contains a single integer Mi indicating the time cost on solving the i-th problem.

(1<=N, M<=100)

[Technical Specification]

T is an integer, and T <= 15;

N and M are integers, 1 <= N, M <= 100.

Mi are integers and, 0 <= Mi <= 100

输出格式

For each test case, print a single line containing a number indicating the maximum sum.

样例

Input
1
10 9
6
1
3
1
5
3
2
5
5
5
Output
10

5 人解决,16 人已尝试。

6 份提交通过,共有 46 份提交。

8.5 EMB 奖励。

创建: 11 年,8 月前.

修改: 3 年,3 月前.

最后提交: 4 年,11 月前.

来源: The 4th Baidu Cup Central China Invitational Programming Contest

题目标签