Editorial for Camila and Books

This problem can be solved by DPDP. For each type ii, Camila has three choices - buy ii-th type, buy n+1in+1-i-th type or skip both. So, if we group each ii and n+1in+1-i type, there will be total n/2n/2 groups. Now, take groups and buy count as state of dp and in each dp state there will be three transitions as skip this group, greedily buy books from ii-th type and greedily buy books from n+1in+1-i-th type and then return the minimum price among them. Overall complexity will be O(XK)O(X * K).

Statistics


80% Solution Ratio

adnan_tokyEarliest, 10M ago

likhon5Fastest, 0.1s

Shuvo_MalakarLightest, 4.3 MB

antihashShortest, 1434B

Toph uses cookies. By continuing you agree to our Cookie Policy.