Can someone please provide any hint on how to solve this question? I am trying to learn dp, If someone could spare some time it would be great.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3839 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | Geothermal | 3569 |
8 | ecnerwala | 3494 |
9 | Um_nik | 3396 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | Um_nik | 164 |
2 | maomao90 | 162 |
2 | -is-this-fft- | 162 |
4 | atcoder_official | 158 |
4 | cry | 158 |
4 | awoo | 158 |
7 | nor | 155 |
7 | adamant | 155 |
9 | TheScrasse | 153 |
10 | maroonrk | 152 |
Can someone please provide any hint on how to solve this question? I am trying to learn dp, If someone could spare some time it would be great.
Название |
---|
We can solve it without dp too in O(N^2) using contribution to total sum trick, consider an arbitary subarray [l,r] assume this is a single segment and there are separators between Ar & Ar+1 , Al-1, Al , so now we have k-3 separators left to place in left segment and right segment and multiply this product by avaliable gaps in both left and right combined let this number be g , ans+=product*gCk-3 do this for all subarrays and u get the answer.