input: Write a function to calculate the maximum possible revenue from the items with given weights and values using a dynamic programming approach. The function should take in a list of weights, a list of values, and the total capacity of the knapsack, and return the maximum revenue.
  
  
  assert knapsack([2, 1, 3], [4, 2, 3], 3, 5) == 7
  assert knapsack([4, 5, 1], [1, 2, 3], 3, 4) == 3
  assert knapsack([1, 2, 3], [1, 2, 3], 3, 6) == 6
  assert knapsack([4, 5, 6], [1, 2, 3], 3, 3) == 1
  assert knapsack([], [], 0, 5) == 0
  
output: def knapsack(weights, values, n, capacity):
      dp = [[0] * (capacity + 1) for _ in range(n + 1)]
      for i in range(1, n + 1):
          for w in range(1, capacity + 1):
              if weights[i-1] <= w:
                  dp[i][w] = max(dp[i-1][w], values[i-1] + dp[i-1][w-weights[i-1]])
              else:
                  dp[i][w] = dp[i-1][w]
      return dp[n][capacity]