#K9596. Maximum Candy Distribution

    ID: 38979 Type: Default 1000ms 256MiB

Maximum Candy Distribution

Maximum Candy Distribution

Polycarp has n bags and wishes to distribute candies among them. Each bag must contain a unique number of candies, and the number of candies in any bag must lie in the interval \( [x, y] \). To maximize the total number of candies, Polycarp should choose the largest possible numbers from this range. Formally, if he chooses \( n \) distinct integers \( a_1, a_2, \dots, a_n \) with \( x \le a_i \le y \), he wants to maximize the sum \( \sum_{i=1}^{n} a_i \). Note that if \( n > y - x + 1 \), it is impossible to choose \( n \) distinct numbers and you should output \(-1\).

inputFormat

The input is read from standard input and consists of a single line containing three integers ( n ), ( x ), and ( y ) separated by spaces. Here, ( n ) is the number of bags and ( [x, y] ) is the inclusive range of candies that can be assigned to each bag.

outputFormat

Output a single integer to standard output, which is the maximum total number of candies that can be distributed among the ( n ) bags. If it is impossible to have ( n ) distinct numbers within the interval, output (-1).## sample

3 1 5
12