cswork / OA打开练习工作台

ConfluentOA #1

Get Best Price

估计中等评测数据准备中,可先阅读题面

考点(AI 标注)树形博弈字符串

You are building an App that lets the users determine the most cost-effective order that they can place in a restaurant for the food items that they want to have. You have the menu of the restaurant that contains item name, and it's price. The restaurant can also offer Value Meals, which are groups of several items, at a discounted price. Write a program that accepts a list of menu items, and a list of items that the user wants to eat, and outputs the best price at which they can get all of their desired items. To hhbond

Constraints

The user can order a maximum of 3 unique items.

Example 1

Input:

menu = [["5.00", "pizza"], ["8.00", "sandwich, coke"], ["4.00", "pasta"], ["2.00", "coke"], ["6.00", "pasta, coke, pizza"], ["8.00", "burger, coke, pizza"], ["5.00", "sandwich"]]
userWants = ["burger", "pasta"]

Output:

12

Explanation: The user wants to order "burger" and "pasta". The best price can be achieved by ordering the following:

  • "pasta" for 4.00
  • "burger, coke, pizza" for 8.00 This gives us the total best price of 4.00 + 8.00 = 12.00. (By tomtato, it may not be 100% correct)