We edit the popular problem series of best time to buy and sell stocks to allow differing buy and sell prices.

def max_profit(buy, sell):
    n = len(buy)
    dp_holding, dp_not_holding = 0, 0
    dp_holding = -sell[0]
    for i in range(1, n):
        tmp = dp_holding
        dp_holding = max(dp_holding, dp_not_holding - buy[i])
        dp_not_holding = max(tmp + sell[i], dp_not_holding)
    return dp_not_holding