Блог пользователя quangthenpc

Автор quangthenpc, история, 19 месяцев назад, По-английски

Hello. I wanna ask if we can do the CSES Meet in the Middle problem (a.k.a https://cses.fi/problemset/task/1628/) but with subsets having m size.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Yes, you can. Generate the subsets for each half and remember their size and sum. Now when you have some left subset that has size $$$l$$$ and sum $$$s$$$ you just need to count how many right subsets have size $$$m-l$$$ and sum $$$x-s$$$. This can be achieved by doing: binary search / hash map / ordered map.