quangthenpc's blog

By quangthenpc, history, 19 months ago, In English

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.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
19 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

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.