Highway Billboard Leasing accepts a solution that greedily leases the largest offer first
维护者通常 1 天内回复
@PeteChiang1211 已经在做这个了。
开始于 2026年11月26日。
评估
这个 Issue 还没有评估数据。
描述
A solution that sorts the sites by offer and leases each one whose neighbours are still free passes all five house-robber cases, although it is not correct.
Wrong solution (Python):
class Solution:
def bestLeaseRevenue(self, nums):
taken, total = set(), 0
for i in sorted(range(len(nums)), key=lambda i: -nums[i]):
if i - 1 not in taken and i + 1 not in taken:
taken.add(i)
total += nums[i]
return total
It returns the right answer for every case in problem-bank/judges.json ([1, 2, 3, 1], [2, 7, 9, 3, 1], [5], [0, 0, 0], [2, 1, 1, 2]), because in each of them the largest offer belongs to an optimal set.
It fails when the largest offer sits between two smaller offers whose sum is bigger:
| nums | expected | greedy |
|---|---|---|
[2, 3, 2] |
4 | 3 |
[4, 5, 4, 1] |
8 | 6 |
Both inputs are inside the stated domain (1 to 100 sites, offers 0 to 400).
Proposed fix: add a case such as [2, 3, 2] (label along the lines of "largest offer is not in the best set") to the judge, and a test that pins the greedy solution to that case so removing the case fails the test, following the jump-game and stock III judge fixes. I would like to work on this.
- 主要语言
- Rust
- 星标
- 236
- 派生
- 153
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 187
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/codetrial 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 70/100
维护者通常 1 天内回复
-
Unify Java harness validation error messages可能已有人在做 @weichieh0204 今天认领。 未关闭
sysprog21/codetrial#872 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Inferred void class operations are never checked against the starter's return type可能已有人在做 @papaya0112 今天认领。 未关闭
sysprog21/codetrial#871 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Edge Thumbnail Store accepts a store that does not refresh a key on overwrite可能已有人在做 @BOBOGUAGUA428 今天认领。 未关闭
sysprog21/codetrial#869 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 sysprog21/codetrial 的全部 Issue
相似的 Issue
-
bug bugfix
难度 2/5 1-3 小时 新手友好度 78/100
storytold/photocraft#17140 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 70/100
-
bug command Java Edition protocol
难度 2/5 1-3 小时 新手友好度 78/100
Pumpkin-MC/Pumpkin#4733 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
area:parity status:ready-for-agent
难度 2/5 1-3 小时 新手友好度 75/100
neilsh/stunt-reel#1133 ·
维护者通常 1 天内回复