No tags yet

No tag edit access

Time limit per test: 1 second(s)

Memory limit: 262144 kilobytes

Memory limit: 262144 kilobytes

input: standard

output: standard

output: standard

A sports shop has

- each set must contain exactly
*k*dumbbells; - each set must have dumbbells of
*k*distinct masses; - for each pair of sets the masses of dumbbells must coincide , that is, the masses in the sets must be equal as .

The manager's task is to make the maximum number of such sets. If there are several ways to make the maximum possible number of sets, he should choose the one that has the maximum total cost of dumbbells that are contained in the chosen sets. Note that the primary goal is to maximize the number of sets and maximization of the total cost is the secondary goal.

sample input | sample output |

7 2 16 1 4 6 16 7 7 100 32 9 4 6 32 1 | 2 22 |

sample input | sample output |

4 2 1 2 2 1 4 3 1 7 | 1 10 |

In the second sample the manager can make only one set. It consists of the third and the fourth dumbbells.

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/18/2019 00:59:51 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|