Here is a link for the problem.
I found an approach in discussion: "You have to divide the participants into equal teams (rounded)", but I cannot understand why it's correct!
№ | Пользователь | Рейтинг |
---|---|---|
1 | jiangly | 3898 |
2 | tourist | 3840 |
3 | orzdevinwang | 3706 |
4 | ksun48 | 3691 |
5 | jqdai0815 | 3682 |
6 | ecnerwala | 3525 |
7 | gamegame | 3477 |
8 | Benq | 3468 |
9 | Ormlis | 3381 |
10 | maroonrk | 3379 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | -is-this-fft- | 165 |
3 | Dominater069 | 160 |
4 | atcoder_official | 159 |
4 | Um_nik | 159 |
6 | djm03178 | 156 |
7 | adamant | 153 |
8 | luogu_official | 149 |
8 | awoo | 149 |
10 | TheScrasse | 146 |
Название |
---|
In this problem you need to divide them into M teams, so you need to find an array a[1..M] such that its sum is N and its product is maximized.
Okay, suppose there is an optimal sequence of a[] such that there are two elements with difference greater than 1. Then, product is P * X * Y (X + 1 < Y), where P is product of other elements, while X and Y are these two elements with difference greater than 1 (X + 1 < Y).
Now, let's make X++ and Y-- and see what happens. Product becomes P * (X + 1) * (Y — 1) = P * X * Y + P * Y — P * X — P = P * X * Y + P * (Y — X — 1), we know that (Y > X + 1), thus Y — X — 1 at least 1, so answer becomes better.