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時間
- マージ済み PR(30日)
- 187
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日以内に返信