fork download
  1. class Solution {
  2. public int minEatingSpeed(int[] piles, int h) {
  3. int left = 1;
  4. int right = 1000000000;
  5.  
  6. while (left <= right) {
  7. int mid = left + (right - left) / 2;
  8. if (check(piles, mid, h)) right = mid - 1;
  9. else left = mid + 1;
  10. }
  11. return left;
  12. }
  13. public boolean check(int[] piles, int k, int h) {
  14.  
  15. int hours = 0;
  16. for (int pile : piles) {
  17. int div = pile / k;
  18. hours += div;
  19. if (pile % k != 0) {
  20. hours++;
  21. }
  22. }
  23. return hours <= h;
  24. }
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty