Skip to content

Commit

Permalink
Update 001.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed May 15, 2022
1 parent 9dcb95a commit d2b1bf0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions 001.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,29 @@ int main()
// https://qiita.com/drken/items/97e37dd6143e33a64c8c
//

// 解答(最も短いピースの長さ)の候補を表す区間を [left, right) として二分探索
int left = 1;
int right = L + 1;
// 解答(最も短いピースの長さ)の候補を表す区間を二分探索
int ok = 1;
int ng = L + 1;

// 解答を 1 つに絞れないうちは繰り返す
while (1 < (right - left))
while (1 < std::abs(ok - ng))
{
// 試すピースの長さ
const int middle = (left + (right - left) / 2);
const int mid = (ok + ng) / 2;

if (Check(middle, A, K, L)) // そのピースの長さで成立したら
if (Check(mid, A, K, L)) // そのピースの長さで成立したら
{
left = middle;
ok = mid;
}
else
{
right = middle;
ng = mid;
}
}
//
////////////////////////////////

// 解答を出力
std::cout << left << '\n';
std::cout << ok << '\n';
}
```

0 comments on commit d2b1bf0

Please sign in to comment.