An algorithm question, I have no clue to solve it

There are N ingredients available for a chef to cook dishes.

  • For a dish to be tasty, the amount of ingredient i(1<=i<=N) must be between l[i] and r[i]. (r[i] >= l[i]).

  • A dish can fulfil the appetite of a person only if its weight is between L and R.

  • The weight of a dish is the sum of amounts of all ingredients used in its

Write a program to count the number of dishes that are tasty and fulfil the appetite of a person.


Two dishes are considered different if the amount of at least one ingredient is different in both of them.