# | User | Rating |
---|---|---|

1 | Benq | 3650 |

2 | Radewoosh | 3648 |

3 | tourist | 3579 |

4 | ecnerwala | 3551 |

5 | Um_nik | 3494 |

6 | Petr | 3452 |

7 | ksun48 | 3432 |

8 | jiangly | 3349 |

9 | maroonrk | 3338 |

10 | Miracle03 | 3314 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 211 |

2 | awoo | 188 |

3 | Errichto | 187 |

4 | rng_58 | 186 |

5 | SecondThread | 183 |

6 | Um_nik | 176 |

6 | Ashishgup | 176 |

8 | maroonrk | 174 |

9 | antontrygubO_o | 171 |

10 | -is-this-fft- | 169 |

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/12/2021 19:48:26 (j2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Auto comment: topic has been updated by akshayar_01 (previous revision, new revision, compare).This is the 0-1 knapsack problem with an additional constraint. https://cs.stackexchange.com/questions/138476/knapsack-on-two-kinds-of-objects-where-you-cannot-choose-type-2-objects-on-thei

This is 0/1 Knapsack with some additional tweak.

If you don't know what is 0/1 Knapsack : https://www.youtube.com/watch?v=U4O3SwDamA4

After you know how to solve for 0/1 Knapsack, read below.

Dp States :

`dp[i][j][0]`

= The maximum energy we can get from`first i elements`

that have a`weight of j`

and number of Blue objects taken is`even`

.`dp[i][j][1]`

= The maximum energy we can get from`first i elements`

that have a`weight of j`

and number of Blue objects taken is`odd`

.Transitions : Try to find them out, will be a good problem for you.

Solution Code(With Comments, Only see it you have tried writing Transitions) : https://ideone.com/ltzja3