logo AlgoBeat OnlineJudge
登录 注册

#215454. [VKOSHP 2025] Strange Sum

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Given two non-negative integers and .

Also, for all , an integer is given.

For an array of integers , define

You are required to find the maximum possible value of over all arrays such that

输入格式

The input in this problem contains one or more test cases.

The first line contains a single integer -- the number of test cases ().

The descriptions of the test cases follow.

The first line of each test case contains two integers and (, ).

In the -th of the following lines, there are integers ().

输出格式

For each test case, output a single integer: the maximum value of among all arrays such that

样例

样例输入 1

3
5 10
1 1 1 1 1
1 1 1 1
1 1 1
1 1
1
1 10
1
4 1000000000
1 2 3 4
5 6 7
8 9
10

样例输出 1

30
10
14999999995