#P9676. [ICPC 2022 Jinan R] Skills
[ICPC 2022 Jinan R] Skills
题目描述
Prof. Pang has different skills to practice, including soda drinking, fox hunting, and stock investing. We call them Skill , Skill , and Skill . In each of the following days, Prof. Pang can choose one of the three skills to practice. In the -th day (), if Prof. Pang chooses Skill () to practice, his level of Skill will increase by . Initially, Prof. Pang's levels of all skills are .
Prof. Pang forgets skills if he does not practice. At the end of each day, if he has not practiced Skill for days, his level of Skill will decrease by . For example, if he practices Skill on day and Skill on day , at the end of day , he has not practiced Skill for day and has not practiced Skill for days. Then his levels of Skill and Skill will decrease by and , respectively. His level of Skill does not decrease at the end of day because he practices Skill on that day. In this example, we also know that his levels of Skill and Skill both decrease by at the end of day .
Prof. Pang's level of any skill will not decrease below . For example, if his level of some skill is and at the end of some day, this level is decreased by , it will become instead of .
Prof. Pang values all skills equally. Thus, he wants to maximize the sum of his three skill levels after the end of day .
Given (), find the maximum sum.
输入格式
The first line contains a single integer denoting the number of test cases.
For each test case, the first line contains an integer . The -th line contains three integers ( for any ).
It is guaranteed that the sum of over all test cases is no more than .
输出格式
For each test case, output the maximum possible sum of skill levels in one line.
2
3
1 1 10
1 10 1
10 1 1
5
1 2 3
6 5 4
7 8 9
12 11 10
13 14 15
26
41