i am stuck with this dp problem , can any someone explain me the state of dp for this problem ? problem link is Question
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3947 |
2 | jiangly | 3734 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | ecnerwala | 3581 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | ksun48 | 3479 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | awoo | 162 |
2 | maomao90 | 160 |
3 | nor | 156 |
4 | cry | 155 |
4 | adamant | 155 |
4 | atcoder_official | 155 |
4 | -is-this-fft- | 155 |
8 | maroonrk | 153 |
9 | SecondThread | 147 |
10 | Petr | 146 |
i am stuck with this dp problem , can any someone explain me the state of dp for this problem ? problem link is Question
Название |
---|
This is a difficult DP problem until you know the trick. When would a triangle be invalid? Only when one of the side lengths is >= 1/2 of the total sum. With this in mind we can count how many assignments are invalid triangles, rather than how many assignments are valid triangles. This problem is significantly easier — we have 2 parts to our state: current sum and current item. At each spot we have 2 choices — add to our sum or don't. Succeed when our value reaches 1/2 of the total array sum. Total time is O(2 choices * 300 indexes * 300^2 max sum). We can recover the answer by taking 3^N — 3 * the result of our DP.
What about the difference property. Difference of 2 sides must be smaller than third
That should be covered by the same logic.
What you said isn't much clear. But I understood is by subset sum problem we can find the number of ways to make every sum. Then we can add the counts for the numbers greater than n/2 Is that right
If you have |A-C|>B and A+B+C=X then A or C must be >= X/2