Joint Pricing and Resource Allocation: An Optimal Online-Learning Approach