代码:
class Solution {
public int minEatingSpeed(int[] piles, int h) {
Arrays.sort(piles);
int n = piles.length;
int l=1,r=piles[n-1];
while(l<r){
int k = l+(r-l)/2;
int time = 0;
for(int i=0;i<n;i++){
time += piles[i]/k;
if(piles[i]%k!=0){
time++;
}
}
if(time<=h){
r = k;
}else{
l = k+1;
}
}
return r;
}
}