input: Write a function to calculate the maximum possible revenue from items with given weights and values using a knapsack algorithm. The function should take three parameters: weights (a list of integers representing the weight of each item), values (a list of integers representing the value of each item), and n (an integer representing the number of items). The function should return an integer representing the maximum possible revenue.
  assert knapsack([2, 1, 3], [4, 2, 3], 3)==7
  assert knapsack([1, 2, 3], [5, 3, 4], 3)==9
  assert knapsack([1, 3, 4], [1, 4, 5], 3)==6
  assert knapsack([1, 2, 3], [1, 2, 3], 3)==5
  assert knapsack([], [], 0)==0
output: def knapsack(weights, values, n):
      if n == 0:
          return 0
      dp = [0] * (n + 1)
      for i in range(n):
          for j in range(i, -1, -1):
              if dp[j] + values[i] > dp[j + 1]:
                  dp[j + 1] = dp[j] + values[i]
      return dp[n]