Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd184a2c

Browse files
authored
Merge pull requestneetcode-gh#1061 from benjiwright/main
875. Koko Eating Bananas
2 parents28028a9 +6510f14 commitd184a2c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

‎csharp/875-Koko-Eating-Bananas.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
publicclassSolution
2+
{
3+
publicintMinEatingSpeed(int[]piles,inth)
4+
{
5+
intleft=1,right=piles.Max();
6+
varresult=right;
7+
8+
while(left<=right)
9+
{
10+
varmid=left+(right-left)/2;
11+
longhours=0;
12+
foreach(varpileinpiles)
13+
{
14+
hours+=(int)Math.Ceiling(pile/(double)mid);
15+
}
16+
17+
if(hours<=h)
18+
{
19+
result=Math.Min(result,mid);
20+
right=mid-1;
21+
}
22+
else
23+
{
24+
left=mid+1;
25+
}
26+
}
27+
28+
returnresult;
29+
}
30+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp