input: Write a function to calculate the maximum possible revenue from items with given weights and values using the 0/1 knapsack problem approach. The function should take three parameters: a list of item weights, a list of item values, and the number of items. The function should return the maximum revenue that can be obtained by selecting a subset of the items such that their total weight does not exceed the given capacity of the knapsack. If the list of weights or values is empty, the function should return 0.
  assert knapsack([2, 1, 3], [4, 2, 3], 3)==7
  assert knapsack([1, 2, 3], [6, 10, 12], 3)==22
  assert knapsack([2, 3, 4], [3, 4, 5], 3)==7
  assert knapsack([], [], 0)==0
  assert knapsack([1, 2], [3, 3], 2)==3
output: def knapsack(weights, values, n):
      if not weights or not values:
          return 0
      capacity = sum(weights)
      dp = [0] * (capacity + 1)
      for i in range(n):
          for w in range(capacity, weights[i] - 1, -1):
              dp[w] = max(dp[w], dp[w - weights[i]] + values[i])
      return dp[capacity]