Intensive Training

시간 제한1초메모리 제한2048 MB

요약
N일 동안 k_i는 감소하지 않고 r_i는 증가하지 않게 두며 각각의 합이 K와 R이 되도록 잡고, k_i 곱하기 r_i의 합을 최대로 만든다.
난이도

어려움10점 중 8점

유형
그리디, 수학, 조합론, 구현
정답자
아직 제출이 없습니다

문제

To prepare for the upcoming ICPC Regional Contest, you decided to train intensively for the next NN days (numbered from 11 to NN). During the intensive training, you want to solve problems from the infamous training platform INCOJ. In INCOJ, each problem has a difficulty rating represented by a non-negative integer. For each rating, there are 1010010^{100} problems that you can pick to solve.

You want to plan a schedule for your intensive training. For day ii, you plan to solve exactly k_ik\_i problems each with difficulty rating r_ir\_i, such that k_ik\_i and r_ir\_i are non-negative integers. In a single day, it is possible that you solve 00 problems with non-zero rating, it means you are not in the mood to solve any problems on that day. Also it is possible to solve multiple problems with difficulty 00, the problem is too easy for you.

The following is the constraint that you made.

  • To focus on quality over quantity, for each day, the number of problems should not be more than the previous day, and the difficulty rating should not be less than the previous day. Formally, k_i−1≥k_ik\_{i-1} ≥ k\_i and r_i−1≤r_ir\_{i-1} ≤ r\_i for 2≤i≤N2 ≤ i ≤ N.
  • To avoid burning out, the total number of problems that you solve must be exactly KK, and the sum of difficulty ratings across all days must be exactly RR. Formally, k_1+k_2+⋯+k_N=Kk\_1 + k\_2 + \cdots + k\_N = K and r_1+r_2+⋯+r_N=Rr\_1 + r\_2 + \cdots + r\_N = R.

You define the productivity for a day as the product of the number of problems that you solve in that day and their difficulty rating. You want to maximize the total productivity across all NN days.

입력

This problem is a multi-case problem. The first line consists of an integer TT (1≤T≤1001 ≤ T ≤ 100) which represents the number of test cases.

Each test case consists of three integers NN RR KK (1≤N,R,K≤1091 ≤ N, R, K ≤ 10^9) in a single line.

출력

For each test case, output a single integer in a single line representing the maximum total productivity.

예제1

  1. 예제 1

    입력
    4
    3 4 7
    2 1 1
    1 1000000000 1000000000
    1043 104812 99818
    
    예상 출력
    9
    0
    1000000000000000000
    10030642