从列表/池中挑选东西的最佳算法?

发布于 2025-01-11 09:47:09 字数 309 浏览 3 评论 0原文

我有一个水果清单 ['Apple', 'Banana', 'Orange', 'Grape']

人 A 想要拿苹果和香蕉

人 B 想要拿苹果和香蕉和橙子

人 C想拿橙子和葡萄

如果你想要的水果被拿走了,你就根本不能摘取任何水果。例如,可能的解决方案是:

  1. A 和 C 拿走所有水果(最优)

  2. B 拿走了苹果、香蕉、橙子

目标是拿走最多数量的水果(解决方案 1),是否有一种算法可以在不尝试所有组合的情况下计算出这一点?

I have a list of fruits ['Apple', 'Banana', 'Orange', 'Grape']

Person A wants to take Apple and Banana

Person B wants to take Apple and Banana and Orange

Person C wants to take Orange and Grape

If a fruit you want is taken, you cannot pick take any fruits at all. For example, the possible solutions for this are:

  1. Person A and Person C takes all the fruits (most optimal)

  2. Person B takes Apple, Banana, Orange

The goal is to take the most number of fruits (solution 1), is there an algorithm for figuring that out without trying all the combinations?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文